jamie_pattison
Well-known member
- Joined
- Sep 9, 2008
- Messages
- 116
- Programming Experience
- Beginner
I am trying to sort a gridview which contains around 10 columns. I have the below code which works to an extent but i cant reverse the procedure (i.e. Ascend the row). In addition im not sure how i could sort multiple columns rather than just one?
page_Load
ViewState("sort") = ""
End Sub
page_Load
ViewState("sort") = ""
End Sub
VB.NET:
Private Sub Gridview1_Sorting(sender As Object, e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles Gridview1.Sorting
Dim dt As DataTable = GetCustomer
If ViewState("sort") = "DESC" Then
dt.DefaultView.Sort = e.SortExpression + " DESC"
Gridview1.DataSource = dt.DefaultView
Gridview1.DataBind()
Else
dt.DefaultView.Sort = e.SortExpression
Gridview1.DataSource = dt.DefaultView
Gridview1.DataBind()
End If
End Sub
Last edited: