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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox entry with spacing

Status
Not open for further replies.

AnNguyen

Programmer
Jul 18, 2002
33
US
I need help with the listbox entry that has spacing.
I can add entry alright, but the list box only keep the first space between words and omit the other no matter what
for example Input the following
1: This is the first Item (with space)
will show you
1: This is the first Item (with space)

if you use Ascii encode for the space
2: This is the%20%20%20second&#32&#32Item%20%20With encode
the list will show you exactly as above

Please some one help me out with this. I use VS 2003 and IE 5/6 (ASP.NET).

Thank you all in advance.



 
why dont you use  , should render as a space.

Regards,

Rob
 
Thank you

It did not work either. The listbox show &nbsp as it is,

may be there some set up from my machine to cause this ???

An
 
Check the page source, it is HtmlEncoding   as   for you? How are you setting the text on the listbox?

________________________________________
Andrew

I work for a gift card company!
 
Thank you
I found the solution, and here it is:

char nbsp = (char) 0xA0;
for (int i = 0; i < DS.Tables[0]Rows.Count; i++)
{
ListItem lI = new ListItem();
lI.Text = DS.Tables[0].Rows[1].ToString();
int l = lI.Text.Length;

for (int n=lI.Text.Length; n < 30; n++)
lI.Text += nbsp;
lI.Text += DS.Tables[0].Rows[2].ToString().Trim();
for (int n=lI.Text.Length; n < 70 ; n++)
lI.Text += nbsp;

lI.Value = DS.Tables[0].Rows[0].ToString();
lstFiles.Items.Insert(i,lI);
}

for icrf I check the page source the HtmlCoding is what you mention, and how and where to set the text onthe list box? would you elaborate on this.

thank again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top