Html.Dropdown - 获得每个选项的值设定为相同的文字? [英] Html.Dropdown - get the the value of each option to be the same as the text?
本文介绍了Html.Dropdown - 获得每个选项的值设定为相同的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图做一些简单 - 我开始学习MVC和我得到一点点困惑。我有产生下面的下拉
I'm trying to do something simple - I'm starting to learn MVC and I'm getting a tad confused. I have a dropdown that produces the following
<selectid="selectMenu" name="selectMenu">
<option value="Weekly">Weekly</option>
<option value="Monthly">Monthly</option>
<option value="Quarterly">Quarterly</option>
<option value="Annually">Annually</option>
</select>
因此,我增加了以下我的看法 -
thus I added the following to my view -
<% string[] rate = new string[]{"Weekly","Monthly","Quarterly","Annually"}; %>
<%: Html.DropDownList("selectMenu", new SelectList(rate))%>
然而,这产生了以下:
However this produced the following:
<select DataTextField="" DataValueField="" Items="System.String[]" SelectedValue="" SelectedValues="" id="selectMenu" name="selectMenu">
<option>Weekly</option>
<option>Monthly</option>
<option>Quarterly</option>
<option>Annually</option>
</select>
我如何获得每个选项的值是相同的文字?
How do I get the the value of each option to be the same as the text?
也许我应该坚持的JavaScript?
Perhaps I should stick to JavaScript?
推荐答案
这有助于<一个href=\"http://stackoverflow.com/questions/1821585/what-html-helper-do-i-use-to-create-a-simple-dropdownlist-that-doesnt-take-in-an\">What HTML帮手做我用它来创建一个简单的DropDownList没有任何变数走?
这篇关于Html.Dropdown - 获得每个选项的值设定为相同的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文