473,472 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2247
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going...
3
by: melanieab | last post by:
Hi, I'm programatically sorting in a datagrid. When a column header is clicked, the sort happens twice for some reason, making it looks like it only sorts in descending order. I can tell it...
7
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
1
by: Jeremy | last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
4
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in...
5
by: DKC | last post by:
Hi, Using VB.NET. I have a datagrid having a strongly typed array of objects as its data source. The data from the array of objects is displayed by means of a table style, which is fine, but...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.