asp.net网格视图分页

问题描述:





我使用asp.net 2010来构建我的Web应用程序,我从数据库中获取数据并显示到gridview它有超过300行,这里我想使用分页。



我给出了属性AllowPaging = True和PageSize = 50,

在设计模式下在网格视图的底部显示像1,2这样的页面索引,但是当我运行到浏览器时,gridview只加载了50行但没有显示页面索引。





请帮忙..



谢谢..

Hi,

I am using asp.net 2010 to build my web application, I am fetching data from database and displaying to gridview it has more than 300 rows, here i want to use paging.

I have given the properties AllowPaging = True and PageSize = 50,
In the design mode its showing page index like 1,2 in the bottom of the gridview, but when i am running in to the browser the gridview loading only 50 rows but not showing page index.


Please help..

thanks..

I希望这会工作





在设计方面:



< asp:gridview id =GridView1runat =serverallowpaging =truepagesize =50onpageindexchanging =GridView1_PageIndexChanging>





在编码端:

protected void GridView1_PageIndexChanging(object sender,GridViewPageEventArgs e)

{

GridView1.PageIndex = e.NewPageIndex;

//在这里调用你的网格绑定数据方法

}
I hope This will Work


At Design Side:

<asp:gridview id="GridView1" runat="server" allowpaging="true" pagesize="50" onpageindexchanging="GridView1_PageIndexChanging">


At Coding Side:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
// call here your Grid Bind Data Method
}






我自己找到了解决方案。



我试图设置一些在RowCreated事件中,gridview单元格的可见性为false。删除此代码后,gridview分页工作正常...





谢谢。 ..
Hi,

I found the solution myself.

I was trying to set some of the gridview cells visibility to false in RowCreated Event.After removal of this code gridview paging is working fine...


Thanks...


检查这个

强制ASP.NET GridView的寻呼机显示 [ ^ ]