asp.net mvc - Select Tag Helper with grouping elements -
does select tag helper in asp.net mvc core have grouping option such 1 shown below. i'm using latest versions of asp.net core , vs2015:
<select> <optgroup label="swedish cars"> <option value="volvo">volvo</option> <option value="saab">saab</option> </optgroup> <optgroup label="german cars"> <option value="mercedes">mercedes</option> <option value="audi">audi</option> </optgroup> </select>
display:
yes. select tag helper can render opt groups options. have provide group
property value when create new selectlistitem
object.
var swedish = new selectlistgroup { name="swedish" }; var german = new selectlistgroup { name="german" }; var optionitems = new list<selectlistitem> { new selectlistitem { value="vovlo", text = "volvo", group = swedish }, new selectlistitem { value="saab", text="saab", group = swedish }, new selectlistitem { value="mercedes", text="mercedes", group = german } , new selectlistitem { value="audi", text ="audi", group = german } }; // use optionitems asp-items when using select tag helper
Comments
Post a Comment