Last post Jan 28, 2016 03:24 AM by Zhi Lv - MSFT
Jan 27, 2016 07:05 PM|Leeeoon|LINK
I have no code behind and would hopefully prefer it stay that way, but I'm just wondering if there's a way to get multiple sorting in Gridview.
For example, I want to sort by the first column and then by the second column and then by the third column if need be.
Jan 28, 2016 12:39 AM|Bulldog248|LINK
How are you getting your data into Gridview? By any chance are you using SQL Server? If you are then you can sort on as many columns as you need. Let me know and perhaps you could provide a sample of your code, it will help.
Jan 28, 2016 12:57 AM|oned_gk|LINK
Setting multiple colname in sortexpression seem to work
SortExpression = "col1,col2,col3"
or modify select command
SELECT * FROM YOURTABLE ORDER BY COl1,COL2,COL3
Jan 28, 2016 03:24 AM|Zhi Lv - MSFT|LINK
Agree with oned_gk, you could use sortexpression, please refer to the following articles:
Besides, if you are using LINQ to query the database, I suggest you could refer to the following code:
var query_orderby2 = from c in svcContext.ContactSet
orderby c.LastName descending,
first = c.FirstName,
last = c.LastName
More details, please check these articles: