user133371 user133371 - 9 months ago 71
ASP.NET (C#) Question

how to handle long text in dropdownlist control in ASP.NET

Possible Duplicate:

Recommendations for dropdown menu items that are too wide?

I have a drop down list which is populated by the database. Its value field contains the record's id, and its option field contains record's text. But the record's text entries are very long and make the drop down so wide that it totally changes the appearance of my webpage. When I cut down the width it also cuts down the text displayed. Is there any way I can make the web page look good and still allow the user to see the full text (like wrapping, scrolling, or something like that)?

How can I handle this?

Answer Source

Try using CSS to add a fixed width to your dropdown, like:

select {width: 150px}

Whilst the dropdown itself will be of a fixed width and may not show all of the text, the option elements should expand to the width of the widest element.

May not work in IE7 and below, in which case the this link may be of some use for those browsers: