---
title: "Sorting by date in Webgrid MVC"  
description: "Sorting by date in Webgrid MVC"  
author: "Anonymous User"  
published: 2018-04-23  
updated: 2018-04-24  
canonical: https://www.mindstick.com/forum/34473/sorting-by-date-in-webgrid-mvc  
category: "ado.net"  
tags: ["asp.net mvc"]  
reading_time: 1 minute  

---

# Sorting by date in Webgrid MVC

I want to show record by [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) wise what is the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) to do [sorting](https://www.mindstick.com/articles/1581/sorting-list-with-side-bar) by date

```
@{
    var grid = new WebGrid(canSort: true, canPage: true, rowsPerPage: 10);
    grid.Bind(Model, autoSortAndPage: false, rowCount: Convert.ToInt32(ViewBag.TotalPost));
    grid.Pager(WebGridPagerModes.All);

}
    <div>
        @grid.Table(tableStyle: "table table-striped",
                                      columns: grid.Columns(
                                     grid.Column("Title", format: @<text>@item.Title</text>),
                                       grid.Column("Date", format: @<text>@item.Date</text>),
                                    )) </div>
```

\

## Replies

### Reply by Anonymous User

just write follwoing code

```
@{
    var grid = new WebGrid(canSort: true, canPage: true, rowsPerPage: 10);
    grid.Bind(Model.OrderByDescending(x=>x.Date), autoSortAndPage: false, rowCount: Convert.ToInt32(ViewBag.TotalPost));
    grid.Pager(WebGridPagerModes.All);
```

hope it resolve your problem


---

Original Source: https://www.mindstick.com/forum/34473/sorting-by-date-in-webgrid-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
