Listbox item need spaces

  • Thread starter Thread starter Manan
  • Start date Start date
M

Manan

hello All,

I have a simple question..I'm creating a tempString that
contains my values then i'm adding to a ListItemCollection
(). In my tempString i'm adding a spaces between each
values it works fine..when I add to a ListBox the HTML
doesn't render the spaces..Anyhelp is appreciated...

Tanks
Manan

code
-----
tempString = memLastName + Space(5) + memFirstName + Space
(5) + MemDob
tempItem = New ListItem()
tempItem.Text = tempString
tempItem.Value() = MemNbr
tempItemCollection.Add(tempItem)

Next

ListBox1.DataSource = tempItemCollection
ListBox1.DataTextField = "Text"
ListBox1.DataValueField = "Value"
ListBox1.DataBind()
 
Is there a question in this somewhere?
I guess it IS a simple question.
Here is the answer to the question " "
 
I had to override the RenderContents method of the listbox control, manually
putting out the <option> tags and data.

Before I wrote the Text of the ListItem out, I replaced all ' ' with
'&nbsp;' to get the desired columned effect.

bill
 
Great Link!

I noticed that the code was using the string writer and I wondered why... so
I tried a little experiment and came up with this function:

Private Function Pad(ByVal numberOfSpaces As Int32) As String

Dim Spaces As String

For items As Int32 = 1 To numberOfSpaces

Spaces &= "&nbsp;"

Next

Return Server.HtmlDecode(Spaces)

End Function



Now you can call it and add as many spaces to the front or back of a drop
down list item:

DropDownList1.Items.Add(Pad(5) & "Indented")



Sincerely,


--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Hi Manan,

Have you tried Justin's code? If you have any questions, please post back.
 
Back
Top