Question

I have a store procedure that handles paging at database level, receiving @PageSize and @PageIndex. I can create another to return @PageCount, given a page size.

Can I make a datagrid do paging at database level without having to develop it outside the control, using the control pager?

It seems default use of datagrid paging receives all query result, and does paging outside the database. It is not good for us, an unnecessary overload.

Was it helpful?

Solution

Set AllowCustomPaging="true" on the aspx. And when databinding do:

mygrid.VirtualItemCount = pageCount; 
mygrid.DataSource = mysource; 
mygrid.DataBind();

Based on your comment "I use ADO connection, command, etc, and after loading results in a list of objects (my entity classes), I make datagrid.DataSource = List;"

OTHER TIPS

If you use an ObjectDataSource control as the DataSourceID of the GridView then it works pretty seamlessly. The ObjectDataSource controls has a couple of parameters where you can tell it the names of the PageIndex and MaxRows properties.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top