Click here to Skip to main content
15,887,683 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
@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
HTML
@Html.DropDownList("IDCountry",String.empty)


please solve my problem.
Posted
Updated 12-Jun-13 3:51am
v2
Comments
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[^].

C#
@Html.DropDownList("IDCountry", (IEnumerable<SelectListItem>)ViewBag.IDCountry, String.empty, new { @class = "span6" })
 
Share this answer
 
C#
@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