2

I successfully added a WebGrid with a DropDownList that displays the correct data. I have each row set up for a user can set an error level for an error alert. So my question is how do I submit (HttPost) the WebGrid back to the Controller? I created a property in my model but this being the first time I working with a WebGrid I am not sure how to accomplish this.

Here is a snippet from my View:

var grid = new WebGrid(Model.UserAlerts,
         defaultSort: "ErrorCategory",
         rowsPerPage: 20);

...

@using (Html.BeginForm())
{       

 <div id="grid">
     @grid.GetHtml(
         tableStyle: "grid",
         headerStyle: "head",
         alternatingRowStyle: "alt",
         columns: grid.Columns(
             grid.Column("ErrorCategory", "Error Category"),
             grid.Column("Error", "Error Name"),             
             grid.Column(header: "Error Level", format: @<text> @Html.DropDownList("ErrorLevelList")</text>)
         )
     )
 </div>

...
}
Nick Kahn
  • 19,652
  • 91
  • 275
  • 406
  • 1
    WebGrid is all querystring based. You can use it with Get forms. So that for instance you can add a filter box above it. But I don't think it's intended to function as a UI to alter your database. You could construct html.actionLinks in the columns, and use those to take you to another page and pass along an id or whatever. And it may be possible to do what you're suggesting with ajax, since that doesn't submit a form at all. But if you're just using a table to show drop downs and want to save the values, webgrid may not be appropriate – Brian White Jun 22 '12 at 20:08

0 Answers0