Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to show selected value in dropdownlist which is in database.but it shows all value and shows default value selected. my code is as follow:
HTML
  @Html.LabelFor(u => u.description, new {@class = "col-sm-3 control-label no-padding-right" })
   <div class="col-sm-6">
 <select  id="description" name="description" class="col-xs-10 col-sm-5" >
                                                                     
 @{
 List<string> hardwarenames = configuration_utility.DataLayer.Models.Machine.getAllhardware ();

 foreach (string description in hardwarenames)
 {
   <option value="@description">@description</option>
 }
}
</select>
                        
 </string></div>

i am using mvc with razor plz help me?
Posted
Updated 3-Jun-14 22:35pm
v3

1 solution

Hi,

I'm not familiar with MVC Razor. In curiosity i googled it for you. Check http://stackoverflow.com/questions/6807256/dropdownlist-set-selected-value-in-mvc3-razor once. It may hekp you.

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