Skip to content
Loading
how to set dropdown value in Edit mode of User Form in MVC.
  1. @model WebApplication2.Models.Employee  
  2.   
  3. @Html.TextBoxFor(a => a.Name)  
  4. @Html.DropDownListFor(a => a.DepartmentId, (IEnumerable)ViewBag.department, "-- Select Department --")  
 
 
0
  • Jaykumar Suthar
    hi, 
    Mohammad Sbeeh
    Thanks for Reply but, as per my code its not about how to populate dropdown,
    i had already do it by jQuery,
     
    also saved data in db from dropdown,
     
    Problem is that when i go in Edit mode and set all value in all control from database then textbox auto set data in control, but in dropdown will not select value. 
    0
  • Mohammad Sbeeh
    Hi Jaykumar,
     
    this article may be help you,
     
    https://codingtips.net/2013/07/17/how-can-bind-a-dropdown-list-in-mvc-and-use-selected-value/  
    -1