尝试将视图 WebGrid 数据提交到控制器 - MVC3
我成功添加了一个带有 DropDownList 的 WebGrid,它显示了正确的数据。我为用户设置的每一行都可以设置错误警报的错误级别。所以我的问题是如何将 WebGrid 提交(HttPost)回控制器?我在模型中创建了一个属性,但这是我第一次使用 WebGrid,我不确定如何完成此操作。
这是我的观点的片段:
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>
...
}
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>
...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论