DotNetGnat
Programmer
ok here is psuedo code...
what am i doing wrong here...the sorting works on the first click but doesnt work on the second click... i wanted it to work both ways...it has got to do something with the post back thing or binding the data again...but not sure where to fix it in the code...
-DNG
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Sub BindData()
If SortExp.Text = "" Then
dgdata("ApprovalDate asc")
Else
dgdata(SortExp.Text)
End If
End Sub
Sub dgdata(ByVal SortField As String)
'code binding the data to the datagrid
end sub
Sub SortCommand_OnClick(ByVal Sender As Object, ByVal E As DataGridSortCommandEventArgs)
dgdata(SortOrder(E.SortExpression).ToString())
End Sub
Function SortOrder(ByVal Field As String) As String
Dim so As String = SortExp.Text
If Field = so Then
SortOrder = Replace(Field, "asc", "desc")
Else
SortOrder = Replace(Field, "desc", "asc")
End If
End Function
what am i doing wrong here...the sorting works on the first click but doesnt work on the second click... i wanted it to work both ways...it has got to do something with the post back thing or binding the data again...but not sure where to fix it in the code...
-DNG