As we all know, from developing Web Forms, using a Gridview, when we access a database and retrieve a Date column, sometimes (for me, most of the time) the string we get back isn’t very pretty. It normally has the time included, etc.

Of course, for the Gridview, all we had to do was go into BoundColumn DataFormatString property and change it to the format needed. By going into the GUI to do this, it would write out all the code on the page necessary to format the date as we wanted.

In MVC, it’s not too much different, though since there’s no visual interface, we need to actually go into the column definition and apply the formatting there.

Here are 2 different ways to do it:

grid.Column("Birth_Date", header: "Birth Date", 
   format: m => m.Birth_Date.ToShortDateString()),
  // define the rest of the columns


grid.Column("Birth_Date", header: "Birth Date", format: 
        (item) => string.Format("{0:MM/dd/yyyy}", item.Birth_Date)
       // define the rest of the columns        

This should get you to a place in which you can adjust your code via the code above and get the formatting you need for your Webgrid