的CheckBoxList多种选择:如何建模绑定背部,并得到所有选择? [英] CheckBoxList multiple selections: how to model bind back and get all selections?
本文介绍了的CheckBoxList多种选择:如何建模绑定背部,并得到所有选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这code:
Html.CheckBoxList(ViewData.TemplateInfo.HtmlField preFIX,myList中)
产生这样的加价:
< UL><立GT;<输入名称=Header.h_dist_cd类型=复选框VALUE =BD/>
<跨度> BD - 距离BD名称和LT; / SPAN>< /李>
<立GT;<输入名称=Header.h_dist_cd类型=复选框VALUE =SS/>
<跨度> SS - 距离SS名称和LT; / SPAN>< /李>
<立GT;<输入名称=Header.h_dist_cd类型=复选框VALUE =DS/>
<跨度> DS - 距离DS名称< / SPAN>< /李>
<立GT;<输入名称=Header.h_dist_cd类型=复选框VALUE =SW/>
<跨度> SW - 距离SW姓名和LT; / SPAN>< /李>
< / UL>
您可以选中多个选择。返回的字符串参数 Header.h_dist_cd
只包含选定的第一个值。什么我需要做的就是其他的检查值?
POST方法的参数如下:
公众的ActionResult编辑(头球冲顶)
解决方案
当你有,你会得到他们的价值观昏迷分隔多个同名的项目
This code:
Html.CheckBoxList(ViewData.TemplateInfo.HtmlFieldPrefix, myList)
Produces this mark-up:
<ul><li><input name="Header.h_dist_cd" type="checkbox" value="BD" />
<span>BD - Dist BD Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="SS" />
<span>SS - Dist SS Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="DS" />
<span>DS - Dist DS Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="SW" />
<span>SW - Dist SW Name </span></li>
</ul>
You can check multiple selections. The return string parameter Header.h_dist_cd
only contains the first value selected. What do I need to do to get the other checked values?
The post method parameter looks like this:
public ActionResult Edit(Header header)
解决方案
when you have multiple items with the same name you will get their values separated with coma
这篇关于的CheckBoxList多种选择:如何建模绑定背部,并得到所有选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文