Answered by:
Any Paging, Sorting Gridview solution out there that will fit my needs????????????

Question
-
User-356562709 posted
Hi all,
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"]; GridView2.DataBind(); }
Thank you!
Friday, May 13, 2011 11:25 AM
Answers
-
User-356562709 posted
Found the solution for my problem here: http://www.codeproject.com/KB/aspnet/EffectivePaging.aspx
Thanks
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 17, 2011 3:57 PM
All replies
-
User1697457068 posted
read below link it may be helpful for u
http://programming.top54u.com/post/ASP-Net-2-0-Gridview-Paging-using-C-sharp.aspx
Friday, May 13, 2011 12:10 PM -
User-356562709 posted
Hello there, thanks for your answer. It was actually very simple to implement but I realized that it brings ALL the rows.
Since my table is HUGE this is something I cannot apply to our environment :(Thanks
Friday, May 13, 2011 4:12 PM -
User-356562709 posted
This is CLOSE!!!: http://msdn.microsoft.com/en-us/library/aa479347.aspx
but still fetches ALL records and then filter them in a list for display.
I think LINQ could be a solution here but I have no experience on that area.
Friday, May 13, 2011 6:05 PM -
User3866881 posted
Hi:)
If you want to do paging and sorting manually with DataTable + GridView, see this:Hope this helps;
Thx
Sunday, May 15, 2011 10:34 PM -
User-356562709 posted
This still returns ALL records from database.
Tuesday, May 17, 2011 3:56 PM -
User-356562709 posted
Found the solution for my problem here: http://www.codeproject.com/KB/aspnet/EffectivePaging.aspx
Thanks
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 17, 2011 3:57 PM