Literal space in a DropDownList

J

Jon Sagara

I'm trying to insert space characters into some ListItems in a DropDownList.
However, ASP.NET is converting my " " into " ". Anyone know
how to insert literal spaces when populating a DDL programmatically?
 
S

Shiva

Did you try adding the space chars directly without   ?
Eg: DropdownList.Items.Add (" ");

I'm trying to insert space characters into some ListItems in a DropDownList.
However, ASP.NET is converting my " " into " ". Anyone know
how to insert literal spaces when populating a DDL programmatically?
 
J

Jon Sagara

Yep. Just like in an HTML page, they are not rendered as spaces.

I have a temporary workaround -- instead of spaces, I am using dashes.

Thanks,
 
M

Mohamed El Ashmawy

You could resolve this problem by using Server.HTMLDecode.
For example, when you add a new item to the list that should be displayed
as "1 3", you use

DropDownList1.Items.Add(Server.HtmlDecode("1  3"));

This should solve your problem.
Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC
 
Joined
Feb 26, 2008
Messages
1
Reaction score
0
I had the same problem. My SQL data source is SQL2000, and all I did was pre-pend char(160) to the field I wanted to indent. For example: select char(160) +<fieldname> from <table>. That worked.
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top