Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sorting in gridview with up and down arrow using mvc4
plz help with some sample sites or code
Posted

1 solution

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

and

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.

[/Update]

[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 NorthwindSales_MvcContrib.zip[^] 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]

Thanks...
 
Share this answer
 
v5
Comments
mohit jain 8-Nov-12 1:58am    
but i want arrow with up and down icons
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.

Thanks...
mohit jain 8-Nov-12 3:25am    
plz tell how i can add arrow up and down...
show some sample code.
See my updated answer and try to implement.
Thanks...
mohit jain 8-Nov-12 23:23pm    
plz give me sample code for css for up and down icons.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900