首页 新闻 会员 周边

asp.net MVC3 能不能对Model里面的集合进行赋值

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-05-04 17:26

比如有这样一个model :student

有三个属性:1,Name(string) 2,Age(int) 3,ItemList(List<Item>)

Item包括两个属性:1,Name(string) 2,Score(int)

前台页面对模型进行展示和编辑时可以使用

@Html.TextBoxFor(p=>p.Name)生成<input id="Name" type="text" value="0" name="Name">

对于ItemList,如果想要展示集合中每一项的Name并编辑Score传到前台,MVC有没有类似@Html.TextBoxFor(p => p.Name)这样的写法,来写一个@Html.TextBoxFor(p => p.Score)来实现Score的传值到Model里面去

coding烫烫烫烫烫的主页 coding烫烫烫烫烫 | 菜鸟二级 | 园豆:222
提问于:2014-05-04 15:13
< >
分享
所有回答(1)
0

for (int i = 0; i < Model.ItemList.Count(); i++)
{

@Html.TextBoxFor(p=>p.ItemList[i].Score)

}

coding烫烫烫烫烫 | 园豆:222 (菜鸟二级) | 2014-05-04 17:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册