您知道如何輕鬆地將字符串數組的內容綁定到View MVC Razor中的DropDownList?將字符串數組綁定到MVC中的DropDownList Razor
public static string[] AgeRagne = new string[] { "Sun", "Mon", "Tues", "Wed" };
更新: 下面的代碼工作。
@Html.DropDownListFor(
model => model.Filter.AgeRange,
new SelectList(Extensions.AgeRange, Model.Filter.AgeRange),
new { @class = "search-dropdown", name = "ageRange" }
)
我只是走真是瘋狂的猜測..但你的意思是'AgeRange'而不是'AgeRagne'? => =>'.. string [] AgeRagne = ...' – 2016-08-02 02:15:33