绑定mvc4下拉列表中的数据集合 [英] Binding The Collection of data in drop down list in mvc4
本文介绍了绑定mvc4下拉列表中的数据集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在有我的观看代码如下。
@if(!Model.DisableBuyButton ||!Model.DisableWishlistButton)
{
@ Html.LabelFor( model => model.EnteredQuantity,new {@class =input-small},:)
@if(Model.AllowedQuantities.Count> 0)
{
@ Html.DropDownListFor(model => model.EnteredQuantity,Model.AllowedQuantities,new {@class =input-small})
}
其他
{
@ Html.TextBoxFor(model => model.EnteredQuantity,new {@class =input-小}}
}
} @ Html.Widget(productdetails_add_info)
这里如果我有ALLOWEDQUANTITIES.COUNT 是>更多然后 0 。我需要 drop 下载列表 数量。
对于示例如果数量 5 我需要 1 , 2 , 3 , 4 , 5 numbers my drop down list。 如果数量 7 i需要 1 , 2 , 3 ,< span class =code-digit> 4 , 5 , 6 , 7 数字 my drop down。
但我的问题 我不能 to 绑定数据 数字 my drop down表示如果数量 5 它只显示 5 编号 drop 向下列表不显示 1 , 2 , 3 , 4 , 5 。
解决方案
i am now having my view code like below.
@if (!Model.DisableBuyButton || !Model.DisableWishlistButton)
{
@Html.LabelFor(model => model.EnteredQuantity, new { @class = "input-small" }, " :")
@if (Model.AllowedQuantities.Count > 0)
{
@Html.DropDownListFor(model => model.EnteredQuantity, Model.AllowedQuantities, new { @class = "input-small" })
}
else
{
@Html.TextBoxFor(model => model.EnteredQuantity, new { @class = "input-small" })
}
} @Html.Widget("productdetails_add_info")
Here if i have the ALLOWEDQUANTITIES.COUNT is more then 0.I need drop down list for quantities.
For example if the quantity is 5 i need 1,2,3,4,5 numbers in my drop down list.And if the quantity is 7 i need 1,2,3,4,5,6,7 numbers in my drop down.
But my problem is i am not able to bind the data like numbers in my drop down that means if the quantity is 5 it simply displaying only 5 number in drop down list not displaying 1,2,3,4,5.
解决方案
这篇关于绑定mvc4下拉列表中的数据集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文