leading space in dropdownlist

Discussion in 'ASP .Net' started by TJS, Feb 11, 2004.

  1. TJS

    TJS Guest

    I am populating a droplist control from a query.

    each line of content in the dropdownlist gets "trimmed" automatically .
    how can I force a leading space to a line in a dropdown list ??
     
    TJS, Feb 11, 2004
    #1
    1. Advertising

  2. The code below has worked for me in the past

    --
    Regards

    John Timney
    Microsoft Regional Director
    Microsoft MVP
    ----------------------------------------------------------------------------
    ------------------------------------
    <blatant plug>
    Professional .NET for Java Developers with C#- ISBN: 1-861007-91-4
    Professional Windows Forms - ISBN: 1861005547
    Professional JSP 2nd Edition - ISBN: 1861004958
    Professional JSP - ISBN:
    1861003625
    Beginning JSP Web Development - ISBN: 1861002092
    </blatant plug>
    ----------------------------------------------------------------------------
    ------------------------------------

    <%@ Page Language="VB" Debug="true" %>
    <script language=VB runat=server>

    Sub Page_Load(Sender As Object, E As EventArgs)

    Dim Padding As String
    Dim writer As New System.IO.StringWriter()
    Dim DecodedString As String

    Padding = "&nbsp;&nbsp;"
    Server.HtmlDecode(Padding, writer)
    Padding = writer.ToString()

    myDropDownList2.Items.Add(Padding & " MVP's")

    Padding = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    Server.HtmlDecode(Padding, writer)
    Padding = writer.ToString()

    myDropDownList2.Items.Add(Padding & " MVP's")

    myDropDownList2.Items.Add("MVP's" & Padding & "Do Their best")


    End Sub



    </script>
    <html>
    <head><title>Padding DropListBox</title></head>

    <body>

    <form fred runat="server">

    <asp:dropdownlist
    id="MyDropDownList2"
    runat="server"
    />

    </form>

    </body>
    </html>






    "TJS" <> wrote in message
    news:...
    > I am populating a droplist control from a query.
    >
    > each line of content in the dropdownlist gets "trimmed" automatically .
    > how can I force a leading space to a line in a dropdown list ??
    >
    >
     
    John Timney \(Microsoft MVP\), Feb 11, 2004
    #2
    1. Advertising

  3. TJS,

    Here's how:

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load

    DropDownList1.Items.Add(Pad(5) & "Item: 1")

    End Sub

    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


    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "TJS" <> wrote in message
    news:...
    > I am populating a droplist control from a query.
    >
    > each line of content in the dropdownlist gets "trimmed" automatically .
    > how can I force a leading space to a line in a dropdown list ??
    >
    >
     
    S. Justin Gengo, Feb 11, 2004
    #3
  4. add: &nbsp;
    This is means Non-Breaking Space in HTML
     
    =?Utf-8?B?TW9zaGl0Y2g=?=, Feb 11, 2004
    #4
  5. Moshitch,

    Just for future knowledge &nbsp; gets trimmed too.

    You have to encode it to get it to work.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "Moshitch" <> wrote in message
    news:...
    > add: &nbsp;
    > This is means Non-Breaking Space in HTML
    >
     
    S. Justin Gengo, Feb 11, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,987
    Bryan Bullard
    Jul 11, 2003
  2. Christian Seberino
    Replies:
    21
    Views:
    1,813
    Stephen Horne
    Oct 27, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    1,114
    Steve Lamb
    Oct 23, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    789
    Michael Hudson
    Oct 24, 2003
  5. John Nagle
    Replies:
    4
    Views:
    619
    James Antill
    Aug 7, 2007
Loading...

Share This Page