Default value for Html.DropdownList [Resolved]

Posted by Rasagna under ASP.NET MVC on 3/3/2016 | Points: 10 | Views : 339 | Status : [Member] | Replies : 1
Hi,
I have a code like
 @Html.DropDownList("groupsListDiv", Model.GroupsList ?? new List<SelectListItem>(), new { @class = "dropdown-list list-group-item", @id = "groupsListDiv" })

how to set a default value say Select Group




Responses

Posted by: Sheonarayan on: 3/3/2016 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
There are several overloads of @Html.DropDownList, use one of them to do this. Just set the startLevel parameter value.

There are several examples explained here - Dropdown list working with ASP.NET MVC - http://www.dotnetfunda.com/articles/show/2918/working-with-dropdownlist-in-aspnet-mvc.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Rasagna, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response