0
@Html.DropDownListFor(model => model.TransferAvailibilities.First().CancellationID, 
(ViewBag.CancellationSchema == null ? null : 
(IEnumerable<SelectListItem>)ViewBag.CancellationSchema), new { @class = "field large" })

And error:

There is no ViewData item of type 'IEnumerable' that has the key 'CancellationID'.

I know that but i will bind data with ajax when i need. And my lambda not work or something for DropDownListFor...

4

2 回答 2

0

像这样创建SelectListViewBag.CancellationSchema

@Html.DropDownListFor(x => x.intClient, new SelectList(Model.Clients, "ClientId", "ClientName"), string.Empty);
于 2012-09-28T10:19:45.593 回答
0

你做错了。请查看此帖子,而不是解释如何以及为什么,它将为您阐明如何使用的内容@Html.DropDownListFor

如何编写一个简单的 Html.DropDownListFor()?

于 2012-09-28T14:22:28.773 回答