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

  ->   drop down list??

Status
Not open for further replies.

raphael232

Programmer
Joined
Jun 9, 2006
Messages
51
Location
GB
Hi, i'm trying to create a drop down list of categories that has indenting based on how deep the category is. I have the following code:

Code:
Dim Items As New ListItemCollection

For Each Row In Categories
    Dim Item As New ListItem

    Item.Text = "   " & Row.fldCategory
    Item.Value = Row.ID
    Items.Add(Item)
Next

lstCategoryID.DataSource = Items
lstCategoryID.DataTextField = "Text"
lstCategoryID.DataValueField = "Value"
lstCategoryID.DataBind()

And as you can see i have added a prefix on Item.Text which adds 3 spaces (or so i would hope). The trouble is that   is being replaced with   when it is rendered on the page.

Until now I have just used # to indent the text but I was wondering if there is a solution to this problem. Appreciate the help. Thanks
 
Your   is in quotes, so it is using that as a string literal. Try using the Ascii code for the SPACE three times...
Code:
Item.Text = Chr(32) & Chr(32) & Chr(32) & Row.fldCategory

Good Luck!
 
Hi, no such luck. It gave me:

<option value="1">Cat 1</option>
<option value="5"> Cat 1 Sub 1</option>
<option value="8"> Cat 1 Sub 1 Sub 1</option>
<option value="6"> Cat 1 Sub 2</option>
<option value="2">Cat 2</option>
<option value="7"> Cat 2 Sub 1</option>
<option value="3">Cat 3</option>

And two spaces are the same as one, so the display had no indenting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top