简体   繁体   中英

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 在此输入图像描述

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

In the gridview sorting event bind your gridview again

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM