I have an ASP DataGrid and I am applying its sort. Well, since I was looking at an example, they had a function similar to a function other than the name, on:
Private Sub dgTasks_SortGrid(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles dgTasks.SortCommand
Dim strSortDirection As String = Session("SortDir")
If strSortDirection = Nothing Then
strSortDirection = " ASC "
Else
If strSortDirection = " ASC " Then
strSortDirection = " DESC "
Else
strSortDirection = " ASC "
End If
End If
Session("SortDir") = strSortDirection
BindData(e.SortExpression & strSortDirection)
End Sub
Well, I'm trying to make shortcuts and make things “easier”, maybe this would be better:
Private Sub dgTasks_SortGrid(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles dgTasks.SortCommand
If Session("SortDir") = Nothing Then
Session("SortDir") = " ASC "
Else
If Session("SortDir") = " ASC " Then
Session("SortDir") = " DESC "
Else
Session("SortDir") = " ASC "
End If
End If
BindData(e.SortExpression & Session("SortDir"))
End Sub
However, when I thought about it, I thought that maybe I Session("SortDir")should make a request every time, and this may have some consequences or disadvantages. But I was not sure. Does anyone have links that would explain the best or preferred method. Thank.
source
share