<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" OnRowEditing="GridView_RowEditing" OnRowUpdating ="GridView_RowUpdating" OnRowCancelingEdit="GridView_RowCancelingEdit" AutoGenerateColumns="False" BackColor="Transparent" DataKeyNames="Id" OnRowDataBound="GridView1_RowDataBound" OnSorting="GridView1_Sorting" Width="682px" style="text-align: left" ShowFooter="True"> <Columns> <asp:BoundField DataField="Id" Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs) Dim sPage As String = e.SortExpression If ViewState("SortOrder").ToString() = sPage Then If ViewState("OrderDire").ToString() = "DESC" Then ViewState("OrderDire") = "ASC" Else ViewState("OrderDire") = "DESC" End If Else ViewState("SortOrder") = e.SortExpression End If bind() End Sub
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" OnRowEditing="GridView_RowEditing" OnRowUpdating ="GridView_RowUpdating" OnRowCancelingEdit="GridView_RowCancelingEdit"
AutoGenerateColumns="False" BackColor="Transparent" DataKeyNames="Id" OnRowDataBound="GridView1_RowDataBound" OnSorting="GridView1_Sorting" Width="682px" style="text-align: left" ShowFooter="True">
<Columns>
<asp:BoundField DataField="Id"
Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs)
Dim sPage As String = e.SortExpression
If ViewState("SortOrder").ToString() = sPage Then
If ViewState("OrderDire").ToString() = "DESC" Then
ViewState("OrderDire") = "ASC"
Else
ViewState("OrderDire") = "DESC"
End If
Else
ViewState("SortOrder") = e.SortExpression
End If
bind()
End Sub