Home > Enterprise >  How can i set html multiple attribute to razor dropdown?
How can i set html multiple attribute to razor dropdown?

Time:04-19

I have this html code :

<select  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?

CodePudding user response:

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" } )
  • Related