feby
feby

Reputation: 139

error The GridView 'GridView1' fired event Sorting which wasn't handled

I am trying to Create two groups In Data Grid like this example http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm but there are an error and I don't know what is the reason or how to solve it enter image description here

Upvotes: 7

Views: 20089

Answers (2)

Nikhil Dongare
Nikhil Dongare

Reputation: 1

In the gridview sorting event bind your gridview again

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

Upvotes: 0

amit dukane
amit dukane

Reputation: 174

Sorting event seems not handled properly here. You can handle it in following manner

<asp:GridView ID="GridView1" runat="server" AllowSorting="true" 
  OnSorting="GridView1_Sorting"> 
</asp:GridView>
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{ 
    dataTable.DefaultView.Sort = e.SortExpression ;
    GridView1.DataSource = dataTable;
    GridView1.DataBind();
}

Upvotes: 10

Related Questions