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. Advertising

  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. Advertising

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

    Iterate through ArrayList using an another ArrayList

    Saravanan Rathinavelu, Aug 16, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    2,741
    Natty Gur
    Aug 19, 2003
  2. Kaidi
    Replies:
    4
    Views:
    2,384
    Kaidi
    Jan 3, 2004
  3. xz
    Replies:
    16
    Views:
    2,376
  4. dorayme
    Replies:
    1
    Views:
    3,809
    dorayme
    Sep 9, 2010
  5. Scott Brookhart

    indenting text in a datagrid

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

Share This Page