GridView分页中遇到的问题 [英] Problem facing in GridView paging
本文介绍了GridView分页中遇到的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上我正在使用gridview1并将80条记录绑定到该gridview1,并且我将寻呼属性作为pagesize = 20.it成功绑定到gridvew。但我的问题是当我再次点击第二页时它只绑定了前20条记录。我正在给我的代码如下...
< asp:GridView ID = gvInbox runat = server < span class =code-attribute> 宽度 = 100% AutoGenerateColumns = False
DataKeyNames = MsgID DataSourceID = < span class =code-keyword> sdsInbox
< span class =code-attribute> ondatabound = gvInbox_DataBound
onselectedindexchanged = gvInbox_SelectedIndexChanged
onrowcommand = gvInbox_RowCommand onrowdatabound = gvInbox_RowDataBound
AllowPaging = True PageSize = 20 < span class =code-attribute>
< span class =code-attribute> onpageindexchanging = gvInbox_PageIndexChanging >
< pagersettings >
position =Bottom
pagebuttoncount =20/>
< pagerstyle < span class =code-attribute> backcolor = LightBlue >
height =30px
verticalalign =Bottom
horizontalalign =Center/>
受保护 void gvInbox_PageIndexChanging( object sender,GridViewPageEventArgs e)
{
gvInbox.PageIndex = e.NewPageIndex;
// gvInbox.DataSource = sdsInbox;
gvInbox.Page.DataBind( );
}
解决方案
我不确定Page.DataBind();
这是有用的对我来说
protected void gridView_PageIndexChanging( object sender,GridViewPageEventArgs e)
{
gridView.PageIndex = e.NewPageIndex;
gridView.DataSource = / * 指定要绑定的数据集* /
gridView.DataBind();
}
来源:
使用C#进行Gridview寻呼 [ ^ ]
使用数据绑定的ASP.NET GridView分页 [ ^ ]
GridView分页 [ ^ ]
错误意味着您只有一个数据源n适用于gridview。在您的情况下,您使用 DataSourceID =sdsInbox以及 gvInbox_PageIndexChanging 绑定gridview。删除一个数据绑定,它会工作。
参考链接:
ASP.NET 2.0的GridView示例:对GridView的数据进行分页和排序 [ ^ ]
GridView分页示例 [ ^ ]
--Amit
Actually i am taking gridview1 and binding 80 records to that gridview1 and i given paging properties as pagesize=20.it is binding to gridvew successfully. but my problem is when i click on second page again it is binding first 20 records only.i am giving my code below...
<asp:GridView ID="gvInbox" runat="server" Width="100%" AutoGenerateColumns="False"
DataKeyNames="MsgID" DataSourceID="sdsInbox"
ondatabound="gvInbox_DataBound"
onselectedindexchanged="gvInbox_SelectedIndexChanged"
onrowcommand="gvInbox_RowCommand" onrowdatabound="gvInbox_RowDataBound"
AllowPaging="True" PageSize="20"
onpageindexchanging="gvInbox_PageIndexChanging">
<pagersettings>
position="Bottom"
pagebuttoncount="20"/>
<pagerstyle backcolor="LightBlue">
height="30px"
verticalalign="Bottom"
horizontalalign="Center"/>
protected void gvInbox_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvInbox.PageIndex = e.NewPageIndex;
//gvInbox.DataSource = sdsInbox;
gvInbox.Page.DataBind();
}
解决方案
I am not sure about Page.DataBind();
this works for me
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { gridView.PageIndex = e.NewPageIndex; gridView.DataSource = /* Specify your dataset you want to bind here */ gridView.DataBind(); }
sources:
Gridview Paging using C#[^]
ASP.NET GridView Paging With Data Bind[^]
GridView Paging[^]
The error means that Only one data source you can apply to the gridview. In your case you are binding the gridview using DataSourceID="sdsInbox" as well as in gvInbox_PageIndexChanging. Delete one databinding, it''ll work.
Refer the links:
GridView Examples for ASP.NET 2.0: Paging and Sorting the GridView''s Data[^]
GridView Paging Sample in ASP.NET[^]
--Amit
这篇关于GridView分页中遇到的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文