selected value for dropdownbox in asp.net mvc using selectlist

Posted by FosterZ on Stack Overflow See other posts from Stack Overflow or by FosterZ
Published on 2010-05-25T13:41:15Z Indexed on 2010/05/25 14:01 UTC
Read the original article Hit count: 341

Filed under:

hi, i have following selectlist for dropdownbox in aspnet mvc.

This is the editEmployee Action controller, so while edit page is displayed i want to display a selectvalue in dropdownbox,since "SelectList" takes 3 parameters one for value,one for text and other is for selected value, here i'm not getting what should i pass in 3rd parameter, coz its asking an object for selected value.


ViewData["DepartmentList"] = new SelectList(DepartmentRepository.GetDepartmentsBySchoolIdInList(ViewData["schoolId"].ToString()),"DepartmentId","DepartmentTitle");

here is the view


=Html.DropDownList("DepartmentList")

© Stack Overflow or respective owner

Related posts about asp.net-mvc