DropDown List Question

  • Thread starter Thread starter marksommerville
  • Start date Start date
M

marksommerville

I have an ASP DropDownList control with 40 ListItems. I want to limit
the display (after the user clicks the down-arrow) to show only 10
items and a scrollbar. Does anyone know how to do this?

Thanks,
 
I have an ASP DropDownList control with 40 ListItems. I want to limit
the display (after the user clicks the down-arrow) to show only 10
items and a scrollbar. Does anyone know how to do this?

Thanks,

A DropDownList does not have a scroll bar, maybe you are talking about
ListBox? And if that's the case, I guess you can rebind the ListBox
when some event happens.
 
A DropDownList does not have a scroll bar, maybe you are talking about
ListBox? And if that's the case, I guess you can rebind the ListBox
when some event happens.

Thanks for the reply but a dropdownlist always displays a scrollbar
after the user clicks the down-arrow to display the options and when
there are more items than it can display. I want to be able to control
the number of items displayed.

Thanks
 
If you change the size attribute of an HTML <select> element it will appear
as a fixed number but will not collapse down to one row after the selection
has been made.

There is an option to use <optgroup> in an HTML <select> but this is not
supported in ASP.NET DropDownList. If you just want another way to organize
those items you might be able to use this hack:
http://weblogs.asp.net/jeff/archive/2006/12/27/dropdownlist-with-optgroup.aspx

Have you considered using an ajax popup with a fixed size ListBox isntead of
a regular DropDownList?
 
Thanks for the reply but a dropdownlist always displays a scrollbar
after the user clicks the down-arrow to display the options and when
there are more items than it can display. I want to be able to control
the number of items displayed.

Thanks

I guess that's not the standard DropDownList of the .net framework.
 
I guess that's not the standard DropDownList of the .net framework.

It is the standard control. Try creating a DDL with 90 items and see
what happens when you expand it.
 
If you change the size attribute of an HTML <select> element it will appear
as a fixed number but will not collapse down to one row after the selection
has been made.

There is an option to use <optgroup> in an HTML <select> but this is not
supported in ASP.NET DropDownList. If you just want another way to organize
those items you might be able to use this hack:http://weblogs.asp.net/jeff/archive/2006/12/27/dropdownlist-with-optg...

Have you considered using an ajax popup with a fixed size ListBox isntead of
a regular DropDownList?
Haven't tried the Ajax solution. It's not a big problem, just looks a
bit crap. I was just wondering if there was an easy solution. Thanks
anyways.
 
On said:
Haven't tried the Ajax solution.  It's not a big problem, just looks a
bit crap. I was just wondering if there was an easy solution. Thanks
anyways.

I say let the browser handle it based on the window size. I think
it's a bigger hassel trying to scroll to the 11th item when 11 items
would fit perfectly fine on the screen.
 
Back
Top