网格视图分页 [英] Grid View Pagination
本文介绍了网格视图分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个的GridView
,我想实现分页功能。这是工作的罚款。
I have a GridView
, and I want to implement Pagination functionality. This is working fine.
protected DataSet FillDataSet()
{
string source = "Database=GridTest;Server=Localhost;Trusted_Connection=yes";
con = new SqlConnection(source);
cmd = new SqlCommand("proc_mygrid", con);
ds = new DataSet();
da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
return ds;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
int newPagenumber = e.NewPageIndex;
GridView1.PageIndex = newPagenumber;
GridView1.DataSource = FillDataSet();
GridView1.DataBind();
}
但问题是每个分页我必须调用 FillDataSet();
。有没有什么办法来制止。任何其他编码方式?
But the problem is for each pagination I have to call FillDataSet();
. Is there any way to stop that. Any other coding approaches?
推荐答案
看一看斯科特·米切尔的文章:的自定义分页在ASP.NET 2.0中使用SQL Server 2005 。
Have a look at Scott Mitchell's article: Custom Paging in ASP.NET 2.0 with SQL Server 2005.
如果您使用的是SQL Server版本pre-2005,然后尝试:的为分页更有效的方法通过大型结果集
If you're using a version of SQL Server pre-2005, then try: A More Efficient Method for Paging Through Large Result Sets
这篇关于网格视图分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文