Simi
Simi

Reputation: 57

How can i set html multiple attribute to razor dropdown?

I have this html code :

<select class="selectpicker" multiple data-live-search="true">
                                                <option>Mustard</option>
                                                <option>Ketchup</option>
                                                <option>Relish</option>
                                            </select>

the multiple key very important to me and try to use in this razor syntax:

@Html.DropDownListFor(x => x.LinksSelected, new SelectList(ViewBag.Tickets[0].Links, "linkID", "linkName")
                                           , new { @class = "selectpicker" , @multiple } )

How can i solve that?

Upvotes: 0

Views: 592

Answers (1)

Yiyi You
Yiyi You

Reputation: 18179

Try to use multiple = "multiple" to replace @multiple:

@Html.DropDownListFor(x => x.LinksSelected, new SelectList(ViewBag.Tickets[0].Links, "linkID", "linkName")
                                           , new { @class = "selectpicker" , multiple = "multiple" } )

Upvotes: 2

Related Questions