4

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)
    {
        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());
    }

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?

2 Answers 2

7

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)
{
    ...
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Bala, what about the Indexing?
0

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/.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.