我在将值绑定到下拉列表时遇到麻烦。
模型
public class DummyModel
{
...
public int? OptionID { get; set; }
...
}
行内视图导致异常
@Html.DropDownListFor(model => model.OptionID, new SelectList(ViewBag.AvailableOptions, "ID", "Name"))
ViewBag的内容
?ViewBag.AvailableOptions
Count = 4
[0]: {[3, Average Speed]}
[1]: {[4, Snails pace]}
[2]: {[1, Super Fast]}
[3]: {[2, Super Slow]}
生成的异常:
System.Web.HttpException:'DataBinding:'System.Collections.Generic.KeyValuePair`2 [[System.Int32,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089],[System.String,mscorlib,Version = 4.0.0.0,文化=中性,
UYOU
相关分类