Click here to Skip to main content
15,915,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Do pagination in Grid view If I am Binding the Grid veiw with dataset. And I don't want to pass the pagination parameters in my stored Proc
Posted
Updated 12-Aug-11 3:49am
v2
Comments
#realJSOP 12-Aug-11 9:32am    
What platform? ASP.Net? WinForms? WPF?
Herman<T>.Instance 12-Aug-11 9:42am    
what have you tried?

1 solution

If you don't want to use a stored proc then you don't have much of a choice.

Try something like this
int pageSize = 10;
int index = 0;

List<DataRow> rows = new List<DataRow>();
for(int x = index; x < datatable.Rows.Count || x < x + pageSize; x++)
{
  rows.Add(datatable.Rows[x]);
}

grid.DataSource = rows;


Of course this means you need to keep the entire DataTable in memory or persisted and retrieved elsewhere. Depending on the size, that could be very inefficient.
 
Share this answer
 
Comments
Herman<T>.Instance 12-Aug-11 10:54am    
if he is using the GridView from ASP.Net he could set PageSize property and OnPageIndexChanged events and ofgcourse AllowPaging = true

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