We help IT Professionals succeed at work.

ASP.NET (VB) SortExpression in gridview - multiple columns?

Hi experts.

I have a basic GridView control in my ASP.NET (VB.NET) web page which is bound using Entity Framework.  My databound columns are sortable using the SortExpression attribute and this all works fine.

One of my columns (Product) on click of sorting, I would like to sort by product, then version (another column called Version) rather than just by Product (which it currently does).

Is this possible and if so, how do I this?

Thanks

Jon
Comment
Watch Question

Paul MacDonaldDirector, Information Systems
CERTIFIED EXPERT

Commented:
I think you'd have to trap the sort click and instruct the query to sort on both criteria.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:

Author

Commented:
@CodeCruiser - that looks like what I want, except I don't want the checkboxes specifying what to sort.  When a user clicks the Product header link for sorting by Product, I want the gridview to automatically sort by Product, Version.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
You can play with the code to get it to work your way. Tutorial gives you an idea.

Author

Commented:
Maybe I'm being incredibly stupid or missing something here, but after reading and re-reading that article, I cannot find any code of use to my needs from which to get an example.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:

Explore More ContentExplore courses, solutions, and other research materials related to this topic.