1

How can I make a divider between options in a select list? I've read it's possible to make a dummy object and then disable it? Is this the easiest way to do it and in case how can I do that?

Solution

<select asp-for="GameId" asp-items="@(new SelectList(ViewBag.Games, "Id", "Name"))" class="form-control">
     <option>Please select your game</option>
     <option disabled>──────────</option>
</select>
Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
J.Kirk.
  • 943
  • 3
  • 12
  • 32
  • 1
    https://stackoverflow.com/questions/899148/html-select-option-separator – Daniel Gale Dec 20 '17 at 13:22
  • thanks I'm not sure how I wasn't able to find that link! – J.Kirk. Dec 20 '17 at 13:27
  • Specify `Group` property for your select list items and the select tag helper will group the tiems for you using `optgroup`. Refer [Select Tag Helper in ASP.NET Core MVC ](https://stackoverflow.com/a/34624217/40521) – Shyju Dec 20 '17 at 14:20

0 Answers0