gpt4 book ai didi

c# - 未处理 Gridview 事件排序

转载 作者:太空狗 更新时间:2023-10-30 00:45:14 26 4
gpt4 key购买 nike

我有一个 GV,我在其中手动绑定(bind)数据。但问题是它给我这个错误:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: The GridView 'gvAgentList' fired event Sorting which wasn't handled.

页面索引也是如此。这是我从后面的代码中编写的函数:

 protected void gvAgentList_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedEntity; //string for Labeling in Master Page!
int selectIdEntity; //int for storing Plan IDs in Plan Page!
GridViewRow row = gvAgentList.SelectedRow;
selectedEntity = row.Cells[2].Text.ToString();
selectIdEntity = Int16.Parse(row.Cells[1].Text.ToString());
Session["EntityIdSelected"] = selectIdEntity;
Session["EntitySelected"] = selectedEntity;
Response.Redirect("~/FrontEnd/Users.aspx?EntityID=" + row.Cells[1].Text.ToString());
}

我不知道我应该在这里使用哪个事件处理程序?当我进行页面索引更改时,它没有调用此函数!有帮助吗?

最佳答案

当您手动进行数据绑定(bind)时,您必须处理它周围的所有事件。

对于排序,您应该有一个处理 GridView 的 Sorting 的处理程序事件(msdn 文档有一个很好的例子)。

<asp:GridView ID="GridView1" OnSorting="GridView1_Sorting" />

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
...
}

关于c# - 未处理 Gridview 事件排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5954354/

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