网格视图(行命令事件以及pageIndex) [英] Grid View (Row Command event along with pageIndex)
本文介绍了网格视图(行命令事件以及pageIndex)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
更改页面行命令的索引后,出现异常索引超出范围.必须为非负数,并且小于集合的大小.
参数名称:索引"
我的代码是"
Hi,
After changing index of the page row command is giving exception "Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
My code is "
int index1 = Convert.ToInt32(e.CommandArgument);
GridViewRow rows = gvd.Rows[index1];"
页面索引更改后,该页面有2行,但是commandArgument的值是11如何克服这个问题,请帮帮我...
after page index changed that page have 2 rows but commandArgument value is 11 how to over come this issue please help me ...
推荐答案
您为什么这样做? :GridViewRow rows = gvd.Rows[index1];"
分页不是这样实现的.您需要做的就是增加页数并重新绑定网格. .NET将自动显示正确的行.
参考: MSDN:GridView.PageIndexChanged事件 [ ^ ]
What and why are you doing this:GridViewRow rows = gvd.Rows[index1];"
Pagination is not implemented like this. All you need to do is increase the page count and rebind the grid. .NET will automatically show the correct rows.
Refer: MSDN: GridView.PageIndexChanged Event[^]
试试这个:
在您的html代码中添加以下内容:
Hi,
try this:
Add the following in your html code:
<asp:GridView ID="gvd" runat="server" AllowPaging="True"
onpageindexchanging="gvd_PageIndexChanging"
以及下面代码中的以下代码:
and the following code in codebehind:
protected void gvd_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvd.PageIndex = e.NewPageIndex;
gvd.DataBind();
}
谢谢
Thank you
这篇关于网格视图(行命令事件以及pageIndex)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文