在Asp.net MVC的Razor视图中添加和删除动态表中的行 [英] Adding and deleting rows in dynamic table in Asp.net mvc razor view

查看:2743
本文介绍了在Asp.net MVC的Razor视图中添加和删除动态表中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来asp.net的MVC。在项目中,我添加一个表,其中用户可以从下拉输入详细信息和选择选项了。并且当用户点击添加按钮行必须被添加到与所有字段表(包括文本框,下拉列表)。此外,当用户点击删除按钮该特定行必须从表中删除。默认情况下在加载页面时,我应该在表中两行所有必填字段。我需要为以下问题的解决方案。

I am new to asp.net mvc. In my project i have to add a table where user can enter details and select options from drop down . And when the user clicks add button a row must be added to the table with all fields(that includes textbox, dropdown list). Also when the user clicks on delete button that particular row must be removed from the table. By default when the page loads I should have two rows in the table with all required fields. I need solution for the following questions


  1. 如何实现上面说的任务。

  2. 我还需要保存表的详细信息。因此,如何对表详细信息传递给控制器​​?

  3. 保存详细信息,当用户点击编辑按钮,我应该加载表中的所有细节后。请帮我在这

我也搜索了很多,但没有一个例子包括动态表格下拉选项。请帮我完成这一任务。预先感谢所有的志愿者。

I also searched a lot but none of the example includes dropdown option in dynamic table. Please help me in this task. Thanks in advance for all the volunteers.

推荐答案

我建议您使用,史蒂夫·桑德森创建的BeginCollectionItem()辅助

I suggest using the BeginCollectionItem() helper that Steve Sanderson created

http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/

它达到你想要什么,他都要通过它一步一步从一个工作示例。我用它在我的几个项目。

it achieves exactly what you want, and he goes over it step by step with a working example. I've used it in several of my projects.

这篇关于在Asp.net MVC的Razor视图中添加和删除动态表中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆