MVC 3 中用于查看列表的保存按钮

发布于 2025-01-05 06:13:46 字数 488 浏览 4 评论 0原文

在MVC3视图中,我有一个由RadioButtons制作的表,由entityObject填充:

@model IEnumerable<Table>  (View is made as "List")

下面我添加了一个回发“保存”按钮:

@using (Html.BeginForm("Save", "MyView", FormMethod.Post, new { ent = Model }))
{
    <input type="submit" value="Save" />
}

并且在控制器中我添加了:

[HttpPost]
public ActionResult Save(List<Table> ent)
{
    // do something
}

但不正确。如何更正代码以返回控制器端的所有列表。 谢谢。

In MVC3 view i have a table made by RadioButtons populated by entityObject:

@model IEnumerable<Table>  (View is made as "List")

Below i added a postBack "Save" button:

@using (Html.BeginForm("Save", "MyView", FormMethod.Post, new { ent = Model }))
{
    <input type="submit" value="Save" />
}

And in controler i added:

[HttpPost]
public ActionResult Save(List<Table> ent)
{
    // do something
}

But is not right. How to correct the code to return all list in controler side.
Thx.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦言归人 2025-01-12 06:13:46

您需要添加正确的代码来在视图中编写单选按钮,否则它们将永远不会在您的发布请求中提交。

顺便说一句,回发是 Webform 中使用的术语,而不是 MVC 中使用的术语。

ASP.NET MVC:回发仍然在这里 得票最多的答案提供了答案。

You need to add the proper code to write the radio buttons in the view, otherwise they will never be submitted in your post request.

By the way, postback is a term used in webforms and not MVC.

The most voted answer for ASP.NET MVC: Is postback still here provides an answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文