网格视图中的分页而不在ASP.net中的存储过程中传递分页参数 [英] Pagination In Grid veiw Without passing paging parameters in Stored Procedure In ASP.net
本文介绍了网格视图中的分页而不在ASP.net中的存储过程中传递分页参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在网格"视图中进行分页如果我将网格"视图与数据集绑定在一起.而且我不想在存储的Proc
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
推荐答案
中传递分页参数.如果您不想使用存储的proc,那么您不希望这样做"有很多选择.
试试这样的
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;
当然,这意味着您需要将整个DataTable保留在内存中,或者在其他地方持久保存和检索.根据大小,效率可能非常低.
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.
这篇关于网格视图中的分页而不在ASP.net中的存储过程中传递分页参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文