How I sort the gridview column after column

I have the following columns in my gridview(VB)

Type   FirstName   LastName    Company   City

How I can sort the gridview firstly by column 1, after that by column 2 and so on.

Thanks in advance.

 

0
Iskra
8/28/2007 2:05:06 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
1056 Views

Similar Articles

[PageSpeed] 58

You can write your SQL SELECT statement this way:

SELECT Type ,  FirstName,   LastName,    Company,   City  FROM yourtable ORDER BY 1 ASC, 2, 3,4, 5

OR

SELECT Type,  FirstName,   LastName,    Company,   City  FROM yourtable ORDER BY  Type  ASC,  FirstName,   LastName,    Company,   City 

You can use ASC or DESC to change any column's sorting direction. By default, the sorting order is ascending (ASC).


Limno

0
limno
8/28/2007 3:20:56 PM

Thanks a lot, Limno!

0
Iskra
8/28/2007 7:14:11 PM
Reply:

Similar Artilces:

When is a column not a column?
I have several extremely similar datawindows that I have to maintain that go against the same table. Recently, I had to add a column to that table, and also add the column to ALL of these datawindows that go against this table. I added the column to the first datawindow, set up the edit control style, etc. I then did a copy/paste of the columns edit control to the remaining dw's (of course remembering to first add the column in SQL). Everything (update props, column specs, column props) seems to indicate that the pasted column is linked to the column I selected, HOWEVER, when I...

remove a gridview column dynamically, removes controls in template columns
I have a interface with a treeview and a gridview. The gridview has two templatefields that handles insert/update/deletes. The gridview is handling editing of different tables so I create the other columns in the gridview dynamically as boundfields. The user selects the table to edit in the treeview. The problem I am having happens when the user selects a table to edit the second time. The code that executes removes all bound fields, (dynamically added when user selected the first table in the treeview), but not the two template fields, and then adds boundfields specifi...

Sort gridview columns manually
I have a gridview and I want to sort multiple columns manually.  Any code snippets will help.  VB please!!!   <asp:GridView ID="grvRequests" runat="server" AllowSorting="true" AutoGenerateColumns="false" DataKeyNames="COUNT_REQUEST_ID"> <FooterStyle CssClass="GridViewFooter" /> <RowStyle CssClass="GridViewRow" /> <SelectedRowStyle CssClass="GridViewSelectedRow" /> <PagerStyle CssClass="GridViewPager" /> <HeaderStyle CssClass="GridViewHeader&quo...

Issue with Template Columns & Bound Columns while updating the data in a GridView control
Hi, I'm facing the below problem (In general, ObjectDataSource is driving me crazy ! ) I have a simple gridview control and an ObjectDataSource is used to populate the grid. I'm trying to update a row and the corresponding tableadapter methods & stored procedure are in place. Each row has 2 checkboxes and 2 textboxes in edit mode. When the change the values in edit mode and hit update, the checkbox values changed are saved into the Database properly, whereas the textbox values are not being saved. If the textbox column is a bound column then the column is updated with <NULL> in...

How to manipulate images and combe multiple database columns into one column in a GridView control
Hi Folks,I'm hoping someone can help me out with something.I am trying to put together a photo album as a learning exercise and have a GridView control with two columns linked to an Access Data Source. In the left hand column (called Image) I want to display the photo and in the right hand column (called Details) I want to provide details such as Date, Location, People and Comments, Camera Type etc. Each of these is columns is taken from the database I have set up.However, I have am having some problems:1: At the moment I have been able to get the image to display (using an image column ...

Datagrid sort -Sorting a column which is mapped to database column
How do I sort a datagrid column ,which is not mapped to database column. I'm able to sort other columns from the same datagrid which are mapped to database column and this grid has one of the columns which is not mapped to database column. But need to know how to sort the column which is not mapped to database column.     needtoknow: How do I sort a datagrid column ,which is not mapped to database column. I'm able to sort other columns from the same datagrid which are mapped to database column and this grid has one of the columns which is not mapped to database ...

Sorting Columns within columns
In sent items, I need to be able to sort first by 'To' and then by 'Date' so that all mail sent to one person is grouped together and in date order. (Bit like the sort you can do in Excel).There only appears to be one sort option. Any ideas anyone? Sort by date first, then by the To, as Sorts normally do a minimum movement approach, that should get you what you want, but it would always be a manual process - you can't store the double sort Cheers Dave -- Dave Parkes [NSCS] Occasionally resident at http://support-forums.novell.com/ You can regist...

Get a Clicked Column Index Integer value for a GridView column using the Sorting Event Handler
I am creating a GridView nested within a UpdatePanel and I got the sorting, paging all down to a sciene using the GridView events handlers. Now, I stumbled to a minor problem that I can't seem to figure out how to go about it. When sorting, I would like the heading color of the clicked sorted column to change (using CSS). I can't seem to dynamically pass the value of the clicked column index to the method. I am using the following reference to change the color of the column but I cannot seem to retreive the value of the clicked index in integer value: GridView1.Columns(trying to...

GridView.Rows(Column=ID_PK) to GridView.Rows(Column=DropDownListTeamplteField)
Hi Guys,I wonder how I can assign the PrimaryKey in each GridView Row to the template field in the same row. whereas the template field is filled with a dropdownlist thatshould show the values for retrieved in a different table through the GridView Row primary key (which serves as the SELECT parameter to get these values) The GridView looks like this:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="C_ID" DataSourceID="GetC_IDs"> <Columns> <asp:BoundField D...

Binding GridView Columns with controls outside the GridView
HiI already posted this issue but couldn't get the proper resolution so making it more clear;Problem is my controls are outside the grid. Like ive text boxes, for First Name and Last Name and dropdown for country. User can fill these fields for entering a new record and also update the existing by selecting it from the grid.Like user selects a row from the grid and its contents will be displayed on the textboxes and drop downs that are out side the grid.Hope i could explain it better now.  RegardsMohsin Shahzad You could use a DetailsView or FormView control that is linked to...

Update GridView Column Content on click of Button which is included as a column in gridview
 I have Gridview wich has 4 columns1.Name of the Person2.Card Amount3.Template Field of TextBox4. Amount After Transfer I want user to enter the amount in the textbox which gets updated as the total amount (Card Amount + Amount Entered in TextBox) in the 4th column of "Amount After Transfer".I hv tried update Panel and Dynamic Populate bt nothing is working coz the textBox doesnt provide any event function in the code behing page.and javascript function doesnt allow me to refer to any control within the gridview.........PLZ HELP ME...............Thanx   You just place a...

How can I control the width of a column in the GridView control.
From searching I see mention of ways to do it before the controls are bound. Is there a simpler way? If not, could someone explain to me how I need to go about it?Here is the code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">   &nbs...

Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once?
 Hi Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once onto the grid? What I mean is some grid that 's as flexible as MS Excel grid for example.  Any suggestions will be very much appreciated.E The Repeater control is a highly customisable data presentation controlRohin.NET developerNever trust a computer you can't throw out a window. - Steve WozniakPlease remember to click on 'Mark as answer', if this post helped you......

Sort on column without highlighting the column
Hi there, I have a grid style datawindow and when I click the column header in order to sort the data the entire column is selected (highlighted). Is there a way to sort by clicking on the column header but without highlighting the entire column? Thanks, Gerry. An aside. I can turn the grid property off, but then I loose the capability to move and resize the columns. Gerry. On 21 Apr 2004 09:35:52 -0700, Gerry <gerico@xs4all.nl> wrote: >Hi there, > >I have a grid style datawindow and when I click the column header in >order to sort the data the enti...

Web resources about - How I sort the gridview column after column - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 12/26/2015 11:41:12 PM