473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView and multiple column sorting: is this a bug?

I have a GridView control that I want to sort on multiple columns when I
click a particular column. For example, I display Last name + ", " + First
name in the first column and display id in the second column. When clicking
on the first column, I want the GridView to sort on LastName and FirstName.
Based on Microsoft's documentation of SortExpression property, all I have to
do is to set SortExpression= LastName,FirstN ame on the first column. But when
the GridView sorts the data, it only applies sorting direction to the second
parameter of the SortExpression. In the above example, if I click on the
first column, the GridView apparently always does sorting by LastName in
ascending order, but the FirstName sort can be either ascending or
descending (depending on whether I clicked the first column once or twice).
I would expect the GridView to sort the entire sort expression on
ascending/descending order, but it looks like the GridView does this only
for the last parameter in the sort expression. Is this a bug or what?
Jun 6 '06 #1
1 3548
If your data is a DataSet, DataTable or DataView, all that the grid is doing
is passing in your SortExpression into the DataView's Sort property and it
appends " DESC" when descending is requested.

-Brock
http://staff.develop.com/ballen

I have a GridView control that I want to sort on multiple columns when
I click a particular column. For example, I display Last name + ", " +
First name in the first column and display id in the second column.
When clicking on the first column, I want the GridView to sort on
LastName and FirstName. Based on Microsoft's documentation of
SortExpression property, all I have to do is to set
SortExpression= LastName,FirstN ame on the first column. But when the
GridView sorts the data, it only applies sorting direction to the
second parameter of the SortExpression. In the above example, if I
click on the first column, the GridView apparently always does sorting
by LastName in ascending order, but the FirstName sort can be either
ascending or descending (depending on whether I clicked the first
column once or twice). I would expect the GridView to sort the entire
sort expression on ascending/descending order, but it looks like the
GridView does this only for the last parameter in the sort expression.
Is this a bug or what?

Jun 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2286
by: James Rosewell | last post by:
I'm getting an error in the following scenario. - A GridView control is bound to an SQLDataSource. - The user selects a column for sorting. - Some time later in code the column used for sorting is removed and the SelectCommand SQL changed so that the field is not returned. - When the GridView is redisplayed an error occurs because the GridView.SortExpression is no longer a valid column. The SortExpression property of the GridView...
3
2320
by: Carlos | last post by:
Hi all, I currently have a Gridview that doess sorting correctly using several fields. However, I do have a checkbox field that when it is checked I do not know how to make its value to persist when the page is sorted after it is changed. I do handle the checkedchanged event, but I do not know if it is there that I need to do something with the whole gridview or just the checkbox that was checked/unchecked.
4
8252
by: samb | last post by:
When I use manual databinding to a GridView control, as bellow. 'Retrive a DataSet from database Dim ds As DataSet = uda.GetUsers(conectionString) 'gvUsers - The GridView gvUsers.DataSource = ds gvUsers.DataBind()
3
6633
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be implemented simultaneously for multiple columns - but the data need only be sorted by a single column at a time. Sorting should be both ascending and descending. I'm currently using a DataView but it's far too slow, because there are a large...
2
5583
by: sivagururaja | last post by:
Hi All, How can i sorting the Gridview Columns via the code behind. When i tried to sorting the column it doesn't work. SqlConnection con = new SqlConnection("Connection string"); con.Open(); SqlCommand cmd = new SqlCommand(str, con); SqlDataAdapter da = new SqlDataAdapter(cmd);
4
11163
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have a vb.net 2.0 app that is loading a GridView with a DataSource that is returned from a function. The definitions in the function are: Dim ReportDS As DataSet = New DataSet Dim ReportTable As System.Data.DataTable = New System.Data.DataTable("SendTo") The ReportTable is populated row by row by data gotten back from the
1
2340
by: l3d007 | last post by:
I used this example straight from msdn in a gridview that already sorts based on each column. For some reason I cannot get it to sort based on two sorting expressions.Is there some property of the grid view i have to set in order for this to work? <%@ Page language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void...
3
1938
by: Nathan Sokalski | last post by:
I have a GridView control with three columns, all BoundField columns. They all have a HeaderText and DataField property set, and the third one has a DataFormatString property as well. When I run my code, the GridView displays two sets of columns. The first set looks exactly as I would expect. The second set, which should not be there anyway, uses the DataField as the header and does not apply the DataFormatString for the third column. What...
2
5404
by: gnewsgroup | last post by:
I have a GridView, in which the header of one column changes depending on the selected value of a DropDownList outside of this GridView. I did this dynamic header through protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) {
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10147
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...
1
10087
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
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...
0
6737
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
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.