Indenting text from an arraylist...

Discussion in 'ASP .Net' started by RAB, Nov 6, 2005.

  1. RAB

    RAB Guest

    I created an arraylist. Some items need to be indented.
    ....
    MyList.Add("Text")
    MyList.Add(" Text2")
    MyList.Add(" Next text")
    .....

    I then databind the arraylist with a datalist control. However, the
    datalist control does not recognize my spaces and places all text
    left-justified. Is there anything I can do to preserve my spaces? The
    indentation follow no pattern and are used to create an outline format.

    Thanks,
    RABMissouri
     
    RAB, Nov 6, 2005
    #1
    1. Advertisements

  2. Hello RAB,

    I would think you're going to have to add some html formatting in your
    display logic. The simplest case would be something along the lines of:

    MyList.Add("Text")
    MyList.Add(" Text2")
    MyList.Add(" Next text")

    Or you could probably do something with the <UL> <LI> html elements. Maybe
    someone will come up with something more clever for you.

    --
    brians
    http://www.limbertech.com


    "RAB" wrote:

    > I created an arraylist. Some items need to be indented.
    > ....
    > MyList.Add("Text")
    > MyList.Add(" Text2")
    > MyList.Add(" Next text")
    > .....
    >
    > I then databind the arraylist with a datalist control. However, the
    > datalist control does not recognize my spaces and places all text
    > left-justified. Is there anything I can do to preserve my spaces? The
    > indentation follow no pattern and are used to create an outline format.
    >
    > Thanks,
    > RABMissouri
    >
    >
     
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=, Nov 6, 2005
    #2
    1. Advertisements

  3. "RAB" <> wrote in
    news::

    > I created an arraylist. Some items need to be indented.
    > ...
    > MyList.Add("Text")
    > MyList.Add(" Text2")
    > MyList.Add(" Next text")
    > ....
    >
    > I then databind the arraylist with a datalist control. However,
    > the datalist control does not recognize my spaces and places all
    > text left-justified. Is there anything I can do to preserve my
    > spaces? The indentation follow no pattern and are used to
    > create an outline format.
    >
    > Thanks,
    > RABMissouri
    >


    RAB,

    When multiple spaces appear in HTML text, the browser will only
    display one space. To display multiple spaces, use the &nbsp;
    construct (it stands for "Non Breaking SPace").

    So your code could be modified like this:

    MyList.Add("Text")
    MyList.Add("&nbsp;&nbsp;&nbsp;Text2")
    MyList.Add("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next text")


    Run this HTML page to see the difference:

    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    Line 1
    <BR/>
    Line 2
    <BR/>
    Line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3
    </BODY>
    </HTML>


    --
    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.
    http://www.crtimmonsinc.com/
     
    Chris R. Timmons, Nov 6, 2005
    #3
    1. Advertisements

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. Saravanan Rathinavelu

    Iterate through ArrayList using an another ArrayList

    Saravanan Rathinavelu, Aug 16, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    3,057
    Natty Gur
    Aug 19, 2003
  2. Darrel
    Replies:
    2
    Views:
    1,858
    Darrel
    Oct 31, 2004
  3. Yama

    Indenting INPUT

    Yama, Nov 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    532
    Daniel Fisher\(lennybacon\)
    Nov 14, 2005
  4. Kaidi
    Replies:
    4
    Views:
    3,078
    Kaidi
    Jan 3, 2004
  5. xz
    Replies:
    16
    Views:
    2,720
  6. Philipp
    Replies:
    6
    Views:
    1,258
    Arne Vajhøj
    May 28, 2008
  7. dorayme
    Replies:
    1
    Views:
    5,294
    dorayme
    Sep 9, 2010
  8. Scott Brookhart

    indenting text in a datagrid

    Scott Brookhart, Jul 23, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    265
    Scott Brookhart
    Jul 24, 2003
Loading...