本文介绍了如何动态preSELECT项目在ASP.NET MVC一个html.DropDownlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法,这是我可以preSELECT项目在页面加载时,或发送到服务器。
这就是我现在所拥有的。
<%= Html.DropDownList(dllMonths
新的SelectList(新名单<串GT;(){
,一,二月,三月,四五,六一,
七五,八五,九五,十月,月,
十二月}),
新平变化{=this.form.submit(); })%GT;
解决方案
设置选择列表的SelectedValue属性,或者把它作为第二个参数的SelectList构造函数。
<%= Html.DropDownList(dllMonths
新的SelectList(新名单()
{,月,二月,三月,
四五,六一,七一,八一,
九·一,十月,11月。,
十二月},
四五),
新平变化{=this.form.submit(); }
)%GT;
is there way thats i can preselect an item when the page loads or posts to the server..
this is what i have right now..
<%=Html.DropDownList("dllMonths",
new SelectList(new List<string>() {
"", "January", "Feburary", "March", "April", "June",
"July", "August", "September", "October", "November",
"December"}),
new { onchange="this.form.submit();" })%>
解决方案
Set the SelectedValue property of the SelectList, or pass it as second parameter to SelectList constructor.
<% = Html.DropDownList ( "dllMonths",
new SelectList ( new List ( )
{ "", "January", "Feburary", "March",
"April", "June", "July", "August",
"September", "October", "November",
"December" },
"April" ),
new { onchange = "this.form.submit();" }
)%>
这篇关于如何动态preSELECT项目在ASP.NET MVC一个html.DropDownlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!