Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto specify numbers of display items in the dropdownlisbox

Status
Not open for further replies.

AnNguyen

Programmer
Jul 18, 2002
33
0
0
US
Hello.

I have a dropdownlist that are populated with data from a table, there will be around 200 items in the list. When i click at the list arrow, it shows 28 items, and i can scroll up and down, Is there way to make the dropdownlist to show 10 items. I try the Dropdownlist.style.add("items","10") in the pageLoad but it didn't work.

Thank in advance for your help.
 
Dropdownlist1.Attributes.Item("Size")=10
or it's
Dropdownlist1.Attributes.Item("Size").Value=10
 
Thanks
unfortunately it does not work, I tried your statements and get the compile error "System.Web.UI.AttributeCollection' does not contain a definition for 'Items'"

Dropdownlist1.Attributes.Add("Size","10") the dropdownlist turn into a listbox (which is not what i want )

Dropdownlist1.Attributes.Add("Items","10") didn't do anything..

will let you know if i can find a solution.

 
>>Is there way to make the dropdownlist to show 10 items

as in after the user clicks on the "V" arrow?

i dont think there is a method for that...

Known is handfull, Unknown is worldfull
 
Funny, I tried RTomes's code
Code:
Dropdownlist1.Attributes.Item("Size")=10
and it worked perfectly
 
>>jbenson001

that will give a ListBox not a dropdown list...

Known is handfull, Unknown is worldfull
 
vbkris... Just realize when I ran the page ..it changed the dropdown to a listbox.. How the hell????????

That is weird
 
thats cause it sets an attribute called "Size" to the <select> html attribute. the difference between a listbox and dropdown list in HTML is:

DropDownList:
<select>
<option>I</option>
<option>AM</option>
<option>Dropdown</option>
</select>

ListBox:
<select size=10>
<option>I</option>
<option>AM</option>
<option>ListBox</option>
</select>


Known is handfull, Unknown is worldfull
 
It is changing it to a listbox (well sort of!) as a DropDownList simply creates HTML <select> tags. If you add a Rows attribute to a HTML <select> tag, the same thing happens (which is by design).

I'm not sure if it is even possible to do what you are asking.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>I'm not sure if it is even possible to do what you are asking.

same thoughts, i really doubt if thats possible...

Known is handfull, Unknown is worldfull
 
For more info, the SIZE attribute of a <select> tag does the following:
The SIZE attribute of SELECT hints that visual browsers should display the element as a list box with the specified number of options visible at any time. A scroll bar would allow access to any non-visible options. The SIZE attribute is especially useful in SELECT elements with numerous OPTIONs and multiple selections allowed. In such a situation, some visual browsers will render the entire list in one large box without scrolling; a suitable SIZE attribute helps such browsers give a more appropriate presentation.




____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top