Solved

default sort order in gridview at Vb.net

Posted on 2014-09-08
3
543 Views
Last Modified: 2014-09-08
Hi Expert,

I have a student gridview, how I can set defualt sort by firstname, lastname and City ...

click header sort works fine, it can sort Asending or descending. I only have problem in default sort when first time load gridview.


Thanks in advance.
0
Comment
Question by:dshi15
3 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 400 total points
ID: 40310706
From:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.sort(v=vs.110).aspx


  myGridView.Sort("FirstName, LastName, City", SortDirection.Ascending);
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 100 total points
ID: 40311188
Do you fill your grid from a database?

If so, simply set the Order By clause of the query / view / stored procedure that you use to fetch the data to the fields on which you want to sort them, something like:

SELECT * FROM YourTable ORDER BY firstname, lastname, City
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question