I have an asp:GridView control that I set for the AllowSorting="True" property:
<asp:GridView ID="gridUsers" runat="server" PageSize="100" ShowHeaderWhenEmpty="True" Width="100%" AllowSorting="True" onrowcreated="gridUsers_RowCreated" onsorting="gridUsers_Sorting"> </asp:GridView>
At design time, the grid looks sortable:

But at runtime, only the middle column is sorted:

How to make asp:GridView sorted in ASP.NET?
Note For asp:GridView with AllowSorting , a Sorting event handler must be present:
protected void gridUsers_Sorting(object sender, GridViewSortEventArgs e) {
Update : I realized what is especially important in the Description column. This is the only column whose display name is correct from the database as is. The rest of the columns I have to fix the display name :
protected void gridUsers_RowCreated(object sender, GridViewRowEventArgs e) { e.Row.Cells[0].Visible = false; //UserGUID e.Row.Cells[1].Text = "User name"; e.Row.Cells[2].Text = "Full name"; //3=Description e.Row.Cells[4].Text = "E-mail"; e.Row.Cells[5].Text = "Active"; e.Row.Cells[5].Visible = false; e.Row.Cells[6].Text = "Account type"; }
Now I just need to figure out the hard part; and sort the columns.
source share