How can I show more than 5 options in a select list dropdown opens .NET Core View

56 views Asked by At

I have a counties select list box on my View. It renders fine with 21 counties, but when I click the dropdown box, only 5 options are showing at a time. I can scroll down or up as needed to get whichever county that I want to select, but my client does not want to scroll as much and asked if I can display 15 to 20 options at a time. Does anyone know how to do this?

<select asp-for="@Model.CountyId" asp-items="@Model.Counties" id="Counties" class="selectCnty form-control" />

I tried size, but that has no impact.

NOTE: I found out why size had no impact. I was overriding the size on the select with the one that I had in the selectCnty style. It was set to 6 in the style. I changed it to 20, and the select list dropdown opens to 20 options.

$(".selectCnty").selectpicker({
    width: '100%',
    size: 20,
    title: 'Select A County'
});
1

There are 1 answers

0
Hiwater On

I found out why size had no impact. I was overriding the size on the select with the one that I had in the selectCnty style. It was set to 6 in the style. I changed it to 20, and the select list dropdown opens to 20 options.

$(".selectCnty").selectpicker({
    width: '100%',
    size: 20,
    title: 'Select A County'
});