Click here to Skip to main content
15,665,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, I have 2 Questions

I'm trying to assign a datareader to gridview in ASP.NET, everything was successful except that i can not select, sort and page my gridview. I've found bunches of examples online but all are not clearly explain. I'll appreciate if any one can help me out with this and a clear explanation of it.

I wan to assign the rows cache by a dataset to TextBox
Prince Antony G 24-Nov-11 6:14am    
1.Why u use DataReader, Go for Dataset Concept it will easy for sorting,paging.
2.I didnt understood your second Question..

1 solution

Normally, I order to sort a gridview record set, we will form a dataview from the datasource table. since dataview object directly supports the overload for Datatable, we go for dataset or datatable as binding source for gridviews. Then we will sort inside the dataview based on the sort expression and bind that view with grid again. So, grid will look as it has sorted by itself.

Now, If you are using Datareader as your Grid Source, then you cannot directly sort the rows. you have to create new DataTable with the columns and rows spicified by DataReader, then use this DataTable for creating Dataview, set the sort expression and sort the view and bind the grid.

Similar case with paging also.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900