Reputation: 151
We have a dropdown list column in ASP.NET MVC 3.0 WebGrid. User will select a item from that list for each row. When i click on submit I need to capture the selected value for each row. Can anyone please give me a sample code for doing this from controller.
Thanks in advance
Upvotes: 1
Views: 2299
Reputation: 4509
You can make a column with DropDownList control using a html helper:
grid.Column("List", header: "List", format: @<text>@Html.DropDownList("selection", someItems)</text>)
Then put the whole grid in a "form" statement, which refers to "Save" action in your controller, and create that "Save" action method like this:
public ActionResult Save(string[] selection) {
[...]
}
Upvotes: 1
Reputation: 182
Why don'y you give telerik.mvc grid a try. It's super smooth and handles such scenarios pretty well. Moreover the effort is pretty less in setting it up.
You can download it as a nuget package.
Examples are here http://demos.telerik.com/aspnet-mvc/grid
Upvotes: 0