C# String Extension & Helper Methods


I enjoyed spending some time after creating some very useful (at least to me 😛 ) C# helper functions for string operation. So here is the gist of it Continue reading “C# String Extension & Helper Methods”

LINQ to XML and XPath


An XML needs to be parsed – I was told the other day. My first questions from experience, how big the XML is going to be? Do we know the schema? The answer : It’s never going to be bigger than few lines, as we use it to store our application’s menu – which may or may not have child(ren). And yes we know the XML schema. Enough said. Continue reading “LINQ to XML and XPath”

Enumerable.Join


If you’re families with Different Types of SQL Joins which are used to query data from more than one tables, LINQ has a JOIN query operator that provide SQL JOIN like behavior (and syntax … depending on which LINQ syntax you prefer Query or Fluent syntax). To drill down LINQ versus SQL join Continue reading “Enumerable.Join”

The short & sweet answer to : Why IQurayable Vs IEnumerble Or, List …


Fact: What happens with IQueryable<T> is different than with sequences. An instance of IQueryable<T> receives an expression tree it can inspect to decide what processing it should perform.

In principle, as soon as we start enumerating the content of object type; say Customers for example, then expression tree it contains gets analyzed, SQL is generated and executed, and the results of the database query are returned as Customers objects.I don’t want to go into detail about how things work here, but Continue reading “The short & sweet answer to : Why IQurayable Vs IEnumerble Or, List …”

Nested Lists ( ‘Jagged List’ )


Just like Jagged Arrays ( ? ) , it is legal to imagine some sort of ‘Jagged List’, or Nested List, which quite similarly lets us come up with multi-dimensional List datastructure hierarchies.

The code below would actually Continue reading “Nested Lists ( ‘Jagged List’ )”

Where Extension Method V/s FindAll


Upon checking on MSDN, the only advantage of FindAll I found is backwards compatibility until .NET 2.0 on the other hand, Where seemed to be introduced in .NET 3.5 … Technically, Where should outperform FindAll for large number of records as despite the observations that on small set, these two would likely perform comparably. The reason is their mechanisms.

FindAll copies the matching elements to a new list, whereas Where just returns a lazily evaluated sequence – no copying is required. That said in the case of “FindAll”, the new List created to contain the results will have to dynamically grow to contain additional results. Memory usage of FindAll will also start to grow exponentially as the number of matching results increases where as … “Where” should have constant minimal memory usage.

Ref : http://stackoverflow.com/a/2260227, http://stackoverflow.com/a/1531756

LINQ


Below are some code snippets that I have prepared initially, if you do not find one that you are looking for, just drop me an E-mail or just a comment below would suffice.

Example Description Download
Data table to LINQ combine the ease of the database access layer with LINQ queries zip
filter asp:GridView using LINQ Depending on what the user has selected from the drop down, records of a gridview is updated zip
Get cells of a selected row get the text of all cells using LINQ and perform queries for Update/Delete/Insert in the datbase zip

 

ASP.NET


Below are some code snippets that I have prepared initially, if you do not find one that you are looking for, just [ drop me an E-mail ] or just a comment below would suffice. Also please note that a demo illustrated in SQL server should also work with MySQL & vice-versa.
Example Description Download
Populate gridview programmatically using MySQL Loading the gridview programmatically using C# from database zip
Gridview with a drop-down filter in the header Filter your gridview with a drop down in the table header zip
Adding controls on the fly in GridView (Esp. with custom user control,) add hyper-link check-boxes dynamically zip
Paging & Sorting in Gridview Programmatically handle paging and sorting events of gridview zip
Insert/Update/Delete using Button field of the DataGridView(Accessing the cell values of the row containing the button clicked) if you want to retrieve the cell values of the row after the button from that row has clicked and to fire database queries zip
Export Gridview to … MS ACCESS / MS EXCEL / CSV zip
Combobox hard-coded values & Database records to gather Loading a combobox, with static items as well as items from database zip
Sending plain text E-mail message from web app to Gmail You can specify from, password, to, subject and message to send an email zip
Caching 1 Simple Page Level Caching zip
Caching 2 Caching SQL Server Caching for certain amount of time zip
Caching 3 SQLServer Automated Caching and Updating Cached version at Regular Intervals and upon Create/Update/Delete operations zip
Caching 4 Partial Page Caching, Multiple & Multi-Level Page caching and … Clearing the cache zip
Shortening GUID Sometimes we want to get the shortest GUID for building URLs or for dynamic file names, So I created a slight variant of GUID zip
Parsing Uri (Query Params) When one has the URL of the page from which QueryParams are wanted but can not use Request.QueryString (when the URL is not of current page, stored in a object in a memory etc) zip
Nested GridViews A basic example of how a grid can become a part of data row of some master table (master – grid ) zip
Nested GridViews + Conditional Formatting Apply conditional formatting to your nested grid zip
Filter DataGrid w/ LINQ An example demonstrating how LINQ can be used to filter out the data from the Data Grid zip
Gridview : JavaScript/jQuey to databing + filter An example demonstrating how to bind data to Gridview using Client Side Script + filtering ( filter as you type ) zip
Nested GridVeiw A gridview inside a gridview zip
Nested Gridview Nested Expandable & Collapsible Gridview (Same Row) zip
Nested Gridview Nested Expandable & Collapsible Gridview (Next Row) zip
Signal R Move Shape + Group Discussion / Chat + etc … zip
G.Drive Spreadsheets Access Google-SpreadSheet Via Gdata And C# zip
Parameter Parsing Parsing parameters from query string zip
Short GUID Get Short (& sweet) : unique strings, unique, not random chars as random may not be unique zip
String Float Double InterConversion zip
2D Array To-String And Vice-Versa zip
Async GridView (Take # 1) Loading the data for the gridview asynchronously from database

  • Poll Approach
  • Wait Approach
zip
CSV to Gridview A sample web app demonstrating how to load gridview from multiple CSV dynamically (one at a time) zip
Crystal Report : Dynamic Binding Conditional Data-binding from multiple tables, after the report has been loaded zip