나는 ASP DataGrid를 가지고 있으며, 정렬 작업을 적용하고 있습니다.세션 변수를보다 효율적으로/선호하는 방법으로 사용 하시겠습니까?
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
글쎄, 내가 바로 가기를 만들 일이 "쉽게"어쩌면이 가장 좋은 것이라고 생각 만들려고 노력 : 음, 예를보고 있었다, 그들은에 이름을 다른 함수에서 유사한 기능을 가지고 :이
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
그러나, 나는 그것에 대해 생각으로, 나는 Session("SortDir")
가 요청 매번을한다 어쩌면 생각과는 어떤 영향을 미치거나 단점이있을 수 있습니다. 그러나 나는 확실하지 않았다. 누구든지 최선의 방법이나 선호하는 방법을 설명하는 링크가 있습니까? 감사.
외부 'If'조건이 중복되지 않습니까? –
예, 그렇습니다. 나는 그것을 생각할 때 타이핑하고 있었다.:) – XstreamINsanity