473,698 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ 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.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Dim lastSortOrder As String
Dim lastSortColumn As String

daStaffList.Fil l(dsStaffList)

If Not IsPostBack Then
ViewState("Last SortOrder") = "ASC"
ViewState("Last SortColumn") = "LastName"
dvStaffList.Sor t = "LastName" & " " & " ASC"
daStaffList.Fil l(dsStaffList)
dgStaffList.Dat aBind()
End If
End Sub

Private Sub dgStaffList_Sor tCommand(ByVal source As Object, ByVal
e As System.Web.UI.W ebControls.Data GridSortCommand EventArgs) Handles
dgStaffList.Sor tCommand
Dim newSortColumn = e.SortExpressio n.ToString()
Dim newSortOrder = "ASC" 'Default value
Dim lastSortColumn = ViewState("Last SortColumn")
Dim lastSortOrder = ViewState("Last SortOrder")
If (newSortColumn. Equals(lastSort Column) And
lastSortOrder.E quals("ASC")) Then
newSortOrder = "DESC"
End If

ViewState("Last SortOrder") = newSortOrder
ViewState("Last SortColumn") = newSortColumn

dvStaffList.Sor t = newSortColumn & " " & newSortOrder
daStaffList.Fil l(dsStaffList)
dgStaffList.Dat aBind()

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

Any help is appreciated

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

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

this.dgStaffLis t.SortCommand += new
System.Web.UI.W ebControls.Data GridSortCommand EventHandler(th is.dgStaffList_ S
ortCommand);

Thanks,
Blaise Pascal Tine (MSFT)
--------------------
From: wa***@arts.endo w.gov (Simon)
Newsgroups: microsoft.publi c.dotnet.framew ork.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**********@go ogle.com
NNTP-Posting-Date: 27 Jun 2003 13:59:33 GMT
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.s yr.edu!news.max well.syr.edu!sn-xit-03!sn-xit-01!sn-
xit-09!supernews.co m!postnews1.goo gle.com!not-for-mailXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1554 29
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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.EventAr gs) Handles MyBase.Load
'Put user code to initialize the page here
Dim lastSortOrder As String
Dim lastSortColumn As String

daStaffList.Fil l(dsStaffList)

If Not IsPostBack Then
ViewState("Last SortOrder") = "ASC"
ViewState("Last SortColumn") = "LastName"
dvStaffList.Sor t = "LastName" & " " & " ASC"
daStaffList.Fil l(dsStaffList)
dgStaffList.Dat aBind()
End If
End Sub

Private Sub dgStaffList_Sor tCommand(ByVal source As Object, ByVal
e As System.Web.UI.W ebControls.Data GridSortCommand EventArgs) Handles
dgStaffList.So rtCommand
Dim newSortColumn = e.SortExpressio n.ToString()
Dim newSortOrder = "ASC" 'Default value
Dim lastSortColumn = ViewState("Last SortColumn")
Dim lastSortOrder = ViewState("Last SortOrder")
If (newSortColumn. Equals(lastSort Column) And
lastSortOrder. Equals("ASC")) Then
newSortOrder = "DESC"
End If

ViewState("Last SortOrder") = newSortOrder
ViewState("Last SortColumn") = newSortColumn

dvStaffList.Sor t = newSortColumn & " " & newSortOrder
daStaffList.Fil l(dsStaffList)
dgStaffList.Dat aBind()

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
1640
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 reading round the newsgroups, it seems that a custom 'IComparer' is the answer, but I'm not quite sure how to do this. Really, how to get at the IComparer that the DataGrid/DataView uses for sorting. Can anyone point me towards a nice example...
2
945
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 datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
1
2057
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 to scroll the table up and down or from right to the left the content of the active cell will be selected as if for copy/paste. How can I deactivate such a behaviour?
3
3123
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 sorts twice because I inserted a messagebox in the dgMouse (MouseUp) event. Before ok is pressed, the table changes from the order it was loaded to ascending order. After ok is pressed, it goes to descending. The code is below. Any idea why...
7
2459
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 Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here
1
2348
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 page. i.e. If I have: IntegerValue StringValue CurrencyValue 0 Item 0 0 1 Item 1 1.23
4
2110
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 codebehind file. I am using c#. Thanks Manny
5
2524
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 I cannot sort the data when I click on the column header. I have set the tablestype.allowsorting = true, but this has no effect.
1
7127
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 the first column in the grid only. I havent found a way to reliably do this yet. I tried putting the following code in the datagrid's mouse down event Dim hti As DataGrid.HitTestInfo
0
2084
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 help........pls urgent ========================================================= <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9027
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
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 we have to send another system
2
2329
muto222
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.