views:

99

answers:

2

is there a grid for asp.net mvc that acts just like the asp.net webforms datagrid
the behavior that I need is to pass to the grid a DataTable without specifying the amount of columns

+1  A: 

In my opinion you should not be using any of the server controls in MVC.

You will need to use a table and iterate through thr required objects, MVC allows much more control over the HTML which meens that you have to do a little more work.

I think you best look at the NerdDinner example.

http://nerddinner.codeplex.com/

And here is an example,

 <table>

      <% foreach (var category in Model) { %>

        <tr>
            <td><%= Html.Encode(category.data) %></td>            
        <tr>

      <% } %>

    </table>
Pino
+2  A: 

Have a look at MvcContrib. They provide a Grid HTML helper, which is very powerful.

I have extended that Grid in my free library, etcetera.Mvc, added AJAX paging, sorting and some more nice options.

kay.herzam
with the mvcContrib grid you have to specify to the grid each column, i have a dynamic datasource (it's a matrix like in reporting services), so i need something like in asp.net webforms, cuz i don't how many columns i'm going to have
Omu
The mvccontrib grid also supports auto columns. See the enclosed samples.
kay.herzam