Dropdown list in mvc3
I have to insert selected drop down list box value and retrieve for update in mvc3 with razor engine so please explain briefly.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jan 16, 2013, 1:43 AM
you can use following code to bide dropdown in MVC 3 with Razor.
public class Role
{
public int RoleId {get;set;}
public int EmployeeId {get;set;}
public string Name {get;set;}
public SelectList RoleSelectList{get;set;}
}
View Side :
@Html.DropDownListFor(m=>m.RoleId, Model.RoleSelectList,"--select--", null)
to retrieve selected value you can use JQuery Post or simple Post form on submit button.
$("#RoleId option:selected").val();
hope this will help you.