Controlling the number of lines displayed in the dropdown menu

Is there a way to control the number of rows displayed in a DropDownList control? I would like it to only display 10 lines, but it defaults to 30. This causes the list to appear higher than the control, rather than below it due to its position on the page.

+1


source to share


3 answers


If ASP.NET renders the DropDownList control as <select>

, then there is no <select>

browser-dependent way to control the number of rows displayed when opened .

A quick test shows that IE 6 displays 27 items out of a list of 27 items, Safari for Windows 3.2.1 shows 22, Firefox 2 shows 20, and Opera 9.6.2 shows 16. The number of detected items may even depend on the total, but I did not check this is because it is pretty obvious, it is not something that you can control.



Adding size="..."

to the control will cause the dropdown to be fixed and it will no longer be a "dropdown" (if you can even do that).

The only solution for this seems to be to implement your own JavaScript based dropdown or buy or download.

0


source


You can paginate the dropdown data source using PagedDataSource and set the PageSize value to 10.



+1


source


Note: I have not tried this with code

Add the attribute "size" with "10" as the value to display 10 rows in the dropdown.

<asp: dropdownlist size = "10" ...>

It works? (I am guessing it as dropdownlist is SELECT tag in html)

0


source







All Articles