Posts

Showing posts from January, 2014

Paging, sorting and searching in mvc + razor

Image
Source: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application The following illustration shows what the page will look like when you're done. The column headings are links that the user can click to sort by that column. Clicking a column heading repeatedly toggles between ascending and descending sort order. Add Column Sort Links to the Students Index Page To add sorting to the Student Index page, you'll change the   Index   method of the   Student   controller and add code to the   Student   Index view. Add Sorting Functionality to the Index Method In   Controllers\StudentController.cs , replace the   Index   method with the following code: public ActionResult Index ( string sortOrder ) { ViewBag . NameSortParm = String . IsNullOrEmpty ( sortOrder ) ? "Name_desc" : "" ; ViewBag . DateSortParm = sortOrder == "D...