SqlDataReader and GridView with pages?

How i can use SqlDataReader binded to GridView to be paged, i have used pageing when i return DataTable and bind it to GridView it runs okay, but when i return SqlDataReader it does not run, it show me an error: this error bellow:
System.Web.HttpException: AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID 'DataGrid1' when AllowPaging is set to true and the selected data source does not implement ICollection. at System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.BaseDataList.DataBind()
baghlafAsked:
Who is Participating?
 
Type25Connect With a Mentor Commented:
If you really wanted to you can write in your own paging for datareader but i don't really see the point?
0
 
Type25Commented:
A sqldatareader is a forward only cursor.

You need to use a dataset iirc
0
 
Abu HamdanEnterprise Architect, PM ExpertCommented:
As i know you cant use Datareader along with paging in datagrid,, since it works as connected to db ,, not like dataset, datatable ,,

see this,

http://forums.asp.net/p/367014/368015.aspx#368015
0
 
baghlafAuthor Commented:
if i write my own paging for datareader, so i cannot benifit from ASP.NET AJAX, i mean the page whole page will post back not using ajax... can you tell me how i can write custom paging for datareader so i can use ajax with it..??
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.