开发者

Gridview Event Sorting is not handled

开发者 https://www.devze.com 2023-03-05 02:50 出处:网络
I have a GV in which I am data binding it manually. But the problem is that it is giving me this err:

I have a GV in which I am data binding it manually. But the problem is that it is giving me this err:

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

Same for the page indexing. Here is the function I wrote to do it from the code behind:

 protected void gvAgentList_SelectedIndexChanged(object sender, EventArgs e)
    {
        s开发者_Python百科tring 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());
    }

I DONT know which event handler should I use here? Its not calling this function when I am doing a page index change! Any help?


When you are manually doing the data binding, you have to handle all the events around it.

For sorting, you should have a handler for GridView's Sorting event (the msdn doc has a good example).

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

and

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


You could handle the sorting event with JavaScript and you probably should remove the sort handling with the backend code. Also dont forget to remove AllowSorting=true all together.

I generally implement jquery datatables for front end handling such as sorting and what not. Here is a link to get you started: http://www.datatables.net/.

0

精彩评论

暂无评论...
验证码 换一张
取 消