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...

Kapil Khandelwal
  • 15,958
  • 2
  • 45
  • 52
Can Ürek
  • 641
  • 12
  • 24

2 Answers2

0

Create SelectList from your ViewBag.CancellationSchema like this:

@Html.DropDownListFor(x => x.intClient, new SelectList(Model.Clients, "ClientId", "ClientName"), string.Empty);
webdeveloper
  • 17,174
  • 3
  • 48
  • 47
0

You doing it wrong. Instead of explaining how and why, please take a look into this posting, will clarify things for you on how to use @Html.DropDownListFor:

How to write a simple Html.DropDownListFor()?

Community
  • 1
  • 1
Display Name
  • 4,672
  • 1
  • 33
  • 43
  • My think that is not wrong syntax or something. I can see now a life cycle problem only. I solve my problem with another way. Render is firing before than lambda expressions... – Can Ürek Sep 28 '12 at 22:07