Example using Datagrid

May 5, 2011 at 8:12 AM


I need Data grid like Excel sheet, Initially it show with a default row and if the user click add then the new row should be added below

and the datas in the first row should be maintained, and finally when he clicks the save the entire rows will save in DB using entity framework.

I have gone through all of your examples and unable to find so . I want to do this with Razor.

May 5, 2011 at 4:34 PM

The grid showed here: http://mvccontrolstoolkit.codeplex.com/wikipage?title=DataGrid%20and%20Pager%20Complete%20Example

Has an add row button. You cabìn start it with just a row with all fileds you need. It is in the file Razor Complete Examples of the binary distribution. Download it an see how it works.


The above grid has two modalities, display and edit. If you want an edit only grid you can use the SortableList with row sorting disabled. You can see an example in the BinariesWithSimpleExamples esxamples that come with the binary distribution.

In the example they use an TypedEditDisplay so that when you click on a filed it becomes a textbox.

All items controls in Mvc Controls Toolkit have an add button you can use to add a row.

When you click save ALL ROWS are saved, ie sent to the Controller that can save them


May 11, 2011 at 6:03 AM

I got it.  Thank you so much.