SqlDataReader and GridView with pages?

Posted on 2007-10-08
Medium Priority
Last Modified: 2013-11-07
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()
Question by:baghlaf
  • 2

Expert Comment

ID: 20033927
A sqldatareader is a forward only cursor.

You need to use a dataset iirc

Expert Comment

by:Abu Hamdan
ID: 20033932
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,


Accepted Solution

Type25 earned 375 total points
ID: 20034027
If you really wanted to you can write in your own paging for datareader but i don't really see the point?

Author Comment

ID: 20039041
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..??

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question