Click here to Skip to main content
12,757,627 members (37,128 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET MVC
Sorting in gridview with up and down arrow using mvc4
plz help with some sample sites or code
Posted 7-Nov-12 20:01pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

For displaying grid of data refer - Displaying a Grid of Data in ASP.NET MVC [^]


for sorting refer Sorting a Grid of Data in ASP.NET MVC[^].

Hope they help you.

[Update] as per comments added by OP.

Take a look at the article - Grid - MvcContrib[^], , which is one grid implementation in MVC.
In the sorting section of that article, it says like below.

When the data has been sorted on a column, the grid will place additional CSS classes in the column headings. If the column is currently sorted in ascending order then the appropriate "th" tag will have a class of sort_asc. Likewise, if the column is sorted in descending order then the css class will be sort_desc. These classes can be used to add additional styling (for example, to add up/down arrows). Please look at the MvcContrib.Examples.UI project for a complete example.
So you can add up and down icons also.
Take a look at MvcContrib Grid Part 6 - Sorting[^] for more details.

Try to implement this.


[Updating again](as per OP's comment)
After so many research, I found one example project, where up and down icons are working on grid sort columns.

Please go through the article ASP.NET MVC Paging/Sorting/Filtering using the MVCContrib Grid and Pager[^]. You will find the demo application or sorce code at the end of the article or just click[^] to download.

I have downloaded it and tested at my local. It works fine and the up down icons also coming on the sorted columns.
[/Updating again]

mohit jain 8-Nov-12 1:58am
but i want arrow with up and down icons
Tadit Dash 8-Nov-12 2:08am
If you can understand the concept of sorting, then you can just try it out to add two images of arrow up and down to the column, which you want to sort.
Then you just need to toggle their visibilty according to the sorting order.

mohit jain 8-Nov-12 3:25am
plz tell how i can add arrow up and down...
show some sample code.
Tadit Dash 8-Nov-12 4:56am
See my updated answer and try to implement.
mohit jain 8-Nov-12 23:23pm
plz give me sample code for css for up and down icons.
Tadit Dash 9-Nov-12 3:45am
Please follow my updated answer inside [Updating again] tags.
You will find aone article link with example codes.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100