I am new to MVC and donβt understand how you will pager and sort by grid. Iβm used to using the asp.Net GridView control with the ObjectDataSource object specified in our business layer objects β in which case ODS handles all the search calls and sorting using the methods that our ORM generates for the objects.
I looked at using the same ORM with MVC - and everything works fine there - I just loop through the collections to build the table on the page - but without ODS to handle swapping and sorting, I am confused about how I can handle this. Will I have a separate controller for swapping and sorting?
I understand that I need to collapse on my own, but where to start? I created a CustomerController and a view that displays a customer table that looks lower - and I want to sort the FirstName or LastName columns. My model has a Sort () method that will accept a string sort expression in the format that the GridView / ODS pair will use. Create a new action on my CustomerController called Sort and put the ActionLink in your header?
<table> <tr> <th> First Name </th> <th> Last Name </th> </tr> <% foreach (var item in Model) { %> <tr> <td> <%= Html.Encode(item.FirstName) %> </td> <td> <%= Html.Encode(item.LastName) %> </td> </tr> <% } %> </table>
Scott Ivey Jan 30 '09 at 17:46 2009-01-30 17:46
source share