469,646 Members | 1,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Datagrid sorting

I have read most messages in regard with this topic, and have tried
every measure suggested. I'm still haveing problem to get it to work.
Basically, the page just reloaded as before when I clicked on the
header link.
Here is the code :
************************************************** **********************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim lastSortOrder As String
Dim lastSortColumn As String

daStaffList.Fill(dsStaffList)

If Not IsPostBack Then
ViewState("LastSortOrder") = "ASC"
ViewState("LastSortColumn") = "LastName"
dvStaffList.Sort = "LastName" & " " & " ASC"
daStaffList.Fill(dsStaffList)
dgStaffList.DataBind()
End If
End Sub

Private Sub dgStaffList_SortCommand(ByVal source As Object, ByVal
e As System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
dgStaffList.SortCommand
Dim newSortColumn = e.SortExpression.ToString()
Dim newSortOrder = "ASC" 'Default value
Dim lastSortColumn = ViewState("LastSortColumn")
Dim lastSortOrder = ViewState("LastSortOrder")
If (newSortColumn.Equals(lastSortColumn) And
lastSortOrder.Equals("ASC")) Then
newSortOrder = "DESC"
End If

ViewState("LastSortOrder") = newSortOrder
ViewState("LastSortColumn") = newSortColumn

dvStaffList.Sort = newSortColumn & " " & newSortOrder
daStaffList.Fill(dsStaffList)
dgStaffList.DataBind()

End Sub
************************************************** ****************************

Any help is appreciated

Simon
Nov 17 '05 #1
2 2105
Hi Simon,

Could you verify that you have the following methods registered under
InitializeComponent(); ?

this.dgStaffList.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.dgStaffList_S
ortCommand);

Thanks,
Blaise Pascal Tine (MSFT)
--------------------
From: wa***@arts.endow.gov (Simon)
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Datagrid sorting
Date: 27 Jun 2003 06:59:33 -0700
Organization: http://groups.google.com/
Lines: 50
Message-ID: <ef**************************@posting.google.com >
NNTP-Posting-Host: 63.169.191.3
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1056722373 18471 127.0.0.1 (27 Jun 2003 13:59:33 GMT)X-Complaints-To: gr**********@google.com
NNTP-Posting-Date: 27 Jun 2003 13:59:33 GMT
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-
xit-09!supernews.com!postnews1.google.com!not-for-mailXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:155429
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

I have read most messages in regard with this topic, and have tried
every measure suggested. I'm still haveing problem to get it to work.
Basically, the page just reloaded as before when I clicked on the
header link.
Here is the code :
************************************************* ***********************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim lastSortOrder As String
Dim lastSortColumn As String

daStaffList.Fill(dsStaffList)

If Not IsPostBack Then
ViewState("LastSortOrder") = "ASC"
ViewState("LastSortColumn") = "LastName"
dvStaffList.Sort = "LastName" & " " & " ASC"
daStaffList.Fill(dsStaffList)
dgStaffList.DataBind()
End If
End Sub

Private Sub dgStaffList_SortCommand(ByVal source As Object, ByVal
e As System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
dgStaffList.SortCommand
Dim newSortColumn = e.SortExpression.ToString()
Dim newSortOrder = "ASC" 'Default value
Dim lastSortColumn = ViewState("LastSortColumn")
Dim lastSortOrder = ViewState("LastSortOrder")
If (newSortColumn.Equals(lastSortColumn) And
lastSortOrder.Equals("ASC")) Then
newSortOrder = "DESC"
End If

ViewState("LastSortOrder") = newSortOrder
ViewState("LastSortColumn") = newSortColumn

dvStaffList.Sort = newSortColumn & " " & newSortOrder
daStaffList.Fill(dsStaffList)
dgStaffList.DataBind()

End Sub
************************************************* ************************** ***
Any help is appreciated

Simon


Nov 17 '05 #2

No, I don't have that method registered.
How would I do that ? and where this code goes?
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Chris Mayers | last post: by
1 post views Thread by Sargas Atum | last post: by
3 posts views Thread by melanieab | last post: by
7 posts views Thread by DC Gringo | last post: by
1 post views Thread by Jeremy | last post: by
4 posts views Thread by Manny Chohan | last post: by
5 posts views Thread by DKC | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.