Click here to Skip to main content
15,567,658 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am unable to get correct value from drop down in mvc4. my edit view code is
@Html.DropDownList("IDCountry", (IEnumerable<SelectListItem>)ViewBag.IDCountry, 
    new { @class = "span6" })

if i use below code am able to get correct value but am unable to apply style for dropdownlist

please solve my problem.
Updated 12-Jun-13 4:51am
Sunasara Imdadhusen 12-Jun-13 9:51am    
have you searched on net?
Anurag Gandhi 12-Jun-13 9:55am    
Do you have the value selected in SelectList? ViewBag.IDCountry??

If you look at the overloads[^], you will see that these two are not the same. If you want to specify default empty value also, I suggest this overload[^].

@Html.DropDownList("IDCountry", (IEnumerable<SelectListItem>)ViewBag.IDCountry, String.empty, new { @class = "span6" })
Share this answer
@Html.DropDownList("IDCountry", (IEnumerable<SelectListItem>)ViewBag.IDCountry,"String"
    new { @class = "span6" })
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900