[英]HTML 5 dropdown in MVC3
I have to render this 我必须渲染这个
<select>
<option data_x="1">Volvo</option>
<option data_x="2">Saab</option>
<option data_x="3">Mercedes</option>
<option data_x="4">Audi</option>
</select>
How can i use Html.DropDownListFor 我如何使用Html.DropDownListFor
[for example:@Html.DropDownListFor(x => x.SelectedPlanCodeID, new SelectList(Model.PlanCodeList, "ID", "Plancode"), " Select ")]
to render this? 渲染这个?
DropDownListFor
doesn't support it natively, you can either do a find/replace on the result of DropDownListFor
or you can write your own HTML helper to do it. DropDownListFor
本身不支持它,您可以对DropDownListFor
的结果进行查找/替换,也可以编写自己的HTML助手来实现。 See this similar question: 看到类似的问题:
ASP.NET MVC: putting custom attributes into option tag in select list ASP.NET MVC:将自定义属性放入选择列表中的选项标签中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.