R
Rolf Barbakken
I have a most annoying problem:
I have a gridview with users from AD. When the user clicks on the header row
a postback is triggered, and the _Sorting-event fires. This is fine, and my
SortGrid-sub is called from there.
But the annoying part is that right after running through SortGrid the
_Sorting-event fires again. SortGrid sorts ASC/DESC alternating, and because
it fires twice every time, the gridview is obviously sorted the same with
every click on a header.
What can be the cause of this?
The code for SortGrid:
Private Sub SortGrid(ByVal sortExpression As String)
Dim dv As Data.DataView
dv = CreateDataSource(lblSortFilter.Text)
If (lblDirection.Text = SortDirection.Ascending.ToString) Then
lblDirection.Text = SortDirection.Descending.ToString
dv.Sort = sortExpression + " DESC"
Else
lblDirection.Text = SortDirection.Ascending.ToString
dv.Sort = sortExpression + " ASC"
End If
grdAnsatte.DataSource = dv
grdAnsatte.DataBind()
End Sub
I have a gridview with users from AD. When the user clicks on the header row
a postback is triggered, and the _Sorting-event fires. This is fine, and my
SortGrid-sub is called from there.
But the annoying part is that right after running through SortGrid the
_Sorting-event fires again. SortGrid sorts ASC/DESC alternating, and because
it fires twice every time, the gridview is obviously sorted the same with
every click on a header.
What can be the cause of this?
The code for SortGrid:
Private Sub SortGrid(ByVal sortExpression As String)
Dim dv As Data.DataView
dv = CreateDataSource(lblSortFilter.Text)
If (lblDirection.Text = SortDirection.Ascending.ToString) Then
lblDirection.Text = SortDirection.Descending.ToString
dv.Sort = sortExpression + " DESC"
Else
lblDirection.Text = SortDirection.Ascending.ToString
dv.Sort = sortExpression + " ASC"
End If
grdAnsatte.DataSource = dv
grdAnsatte.DataBind()
End Sub