Adding carriage returns in asp:listbox

B

BobLaughland

Hi All,

In ASP .NET I have a listbox like this,

<asp:ListBox id="listbox" Height="600" Width="1000" runat="server">
</asp:ListBox>

I want to add items to the listbox (which I am reading out of a
database). Some of those items should appear as one item in the
listbox, but on multiple lines (don't confuse this with multiselect!)

How do I do it?

Let's explain it a bit different, I want to do something like this,

List<string> items = new List<string>();
listbox.DataSource = items;

items.Add("Text to appear on first line \r\n text to appear on
second line");

So in a single selection in the listbox it should have both of the
lines above, and they should be one at the top, and one on the next
line.

But you see that code does not work. I have tried \n, <br\> and many
combinations of the &lt, &gt characters but nothing seems to work.
 
B

bruce barker

the listbox renders as a select and a select does not support this
feature. you will need a custom control to do this. a scrolling div with
anchors would probably do it.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top