当视图从ViewData获取以及用户输入时,如何将数据从视图绑定到列表中 [英] how to bind data into list from view when view is getting from ViewData along with user input
本文介绍了当视图从ViewData获取以及用户输入时,如何将数据从视图绑定到列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i have a dynamic grid/table having three column but multiple rows.
i m binding that grid from different table through ViewData & i have to insert whole grid data along with user input text into another table.
推荐答案
嗨..我理解你的要求你有创建动态名称以输入文本。
例如
int i = 0;
foreach(列表中的var项< item>)
{
@html.textbox(data.items [@i],新{@ id = @ i})
}
然后提交它会将数据发布到控制器,你可以把它放在一个列表中。
Hi ..As i have understood your requirement that you have to create the dynamic names to input text.
for example
int i=0;
foreach( var item in list<item>)
{
@html.textbox("data.items[@i]",new{@id=@i})
}
then on submit it will post the data to controller and you can get it in a list .
这篇关于当视图从ViewData获取以及用户输入时,如何将数据从视图绑定到列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文