GridView _Sorting-event triggers twice every time user clicks on header

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
 
Joined
Sep 3, 2006
Messages
2
Reaction score
0
Sorting event fires twice - is the problem solved or any workaround

I have been having the same problem as this post. The GridView sorting event fires twice when i have an imagebuttuon in the columns of the Grid.

Is the problem solved or is there any workaround for this.
I would really appreciate all the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top