gpt4 book ai didi

c# - 未处理的 GridView 触发事件 PageIndexChanging

转载 作者:可可西里 更新时间:2023-11-01 08:38:51 25 4
gpt4 key购买 nike

我已经允许分页并添加了以下代码但出现了错误。有谁知道可能是什么问题?

代码:

  protected void SubmitAppraisalGrid_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
SubmitAppraisalGrid.PageIndex = e.NewSelectedIndex;
SubmitAppraisalGrid.DataBind();

}

设计:

<asp:GridView ID="SubmitAppraisalGrid" runat="server" 
AutoGenerateColumns="False" BorderWidth="0px"
onrowcreated="SubmitAppraisalGrid_RowCreated" ShowHeader="False"
style="margin-right: 0px" AllowPaging="True" PageSize="1"
onselectedindexchanging="SubmitAppraisalGrid_SelectedIndexChanging">
</asp:GridView>

最佳答案

If you have set a gridviews AllowPaging attribute to “true” and do not handle the PageIndexChanging event then this error raise.

要使用分页,请将 PageIndexChanging 事件处理程序添加到网格并将您的标记和代码更改为:

<asp:GridView ID="SubmitAppraisalGrid" runat="server" 
AutoGenerateColumns="False" BorderWidth="0px"
onrowcreated="SubmitAppraisalGrid_RowCreated" ShowHeader="False"
style="margin-right: 0px" AllowPaging="True" PageSize="1"
onselectedindexchanging="SubmitAppraisalGrid_SelectedIndexChanging"
OnPageIndexChanging="SubmitAppraisalGrid_PageIndexChanging">
</asp:GridView>

///

protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
SubmitAppraisalGrid.PageIndex = e.NewPageIndex;
SubmitAppraisalGrid.DataBind();

//bindGrid();
//SubmitAppraisalGrid.PageIndex = e.NewPageIndex;
//SubmitAppraisalGrid.DataBind();
}

protected void SubmitAppraisalGrid_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
/// you selected index related logic here.
}

当您以编程方式设置 PageIndex 时不会引发此事件属性(property)。查看 GridView.PageIndexChanging Event 的 MSDN 文档

供引用: The GridView fired event PageIndexChanging which wasn't handled

关于c# - 未处理的 GridView 触发事件 PageIndexChanging,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9731645/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com