This is a migrated thread and some comments may be shown as answers.

[Solved] Setting default values in a dropdown list based on a model

0 Answers 32 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peter
Top achievements
Rank 1
Peter asked on 08 May 2012, 08:36 PM
I have a dropdown list of Roles, (see below), and I would like to default the selected value(s) to be based on a value from a model passed in.  How would I set the selected value (initially) based on the model.roles field that has the data stored in a comma delimited result ?  The value of model.roles would be something like "admin,user,siteAdministrator" and I would like all 3 of this values select in the list below....

 

      @model Portal.DAL.Manage.Entities.LAYOUTS
 

      @(Html.Telerik().DropDownList()
             .Name("packageName")
                .BindTo((SelectList)ViewBag.ddlpackages)
                .HtmlAttributes(new { @Style = "width:250px" }))    

 

Tags
ComboBox
Asked by
Peter
Top achievements
Rank 1
Share this question
or