I have found and tested many samples out there and later realized they were not working because my Gridview is actually binding to a DataTable.
The reason for that is that before binding it I am adding extra columns in my DataTable.
I am looking for a good sample code which will show me how to show a Gridview with Sorting and Paging features. I know that can easily be done with SqlDataSource, ObjectDataSrouce or even LINQ to SQL but since I am modifying the Table structure on the fly I am not sure how to implement Paging and Sorting in this situation.
Here is part of my code:
//Load New values from table
DataTable dtNewRecords = FillDataGridView_JobHistory(dateBegin, dateEnd, jobName, clientName);
if ( dtNewRecords != null )
//Finally bind the gridview
GridView2.DataSource = dtNewRecords;
//Sort by the selected column
dtNewRecords.DefaultView.Sort = (String)ViewState["SortExpression"] + " " + (String)ViewState["SortDirection"];
View Complete Post