views:

79

answers:

1

What is wrong with this ?

<%=Html.DropDownListFor(m=>m.Client,null,"Select",new { @style = "width: 630px" })%>

There is a ViewData["Client"] which contanins the source , the dropdown is filled but is not selected the value corresponding to Model.Client

+2  A: 

Change ViewDate["Client"] to ViewData["ClientList"] and put it instead of null .Dont forget to cast it to SelectList.

<%=Html.DropDownListFor(m=>m.ClientId,(SelectList)ViewData["ClientList"],"Select",new { @style = "width: 630px" })%>

Hope this helps.

ali62b
Check out this link for best practice :http://odetocode.com/Blogs/scott/archive/2010/01/18/drop-down-lists-and-asp-net-mvc.aspx
ali62b