Datalist with more than one column

Discussion in 'ASP .Net Web Controls' started by Frank, Sep 29, 2004.

  1. Frank

    Frank Guest

    Hi all,

    I'm having this challenge:
    I have a datalist, which I display in more than one column
    (RepeatColumns="3") and RepeatDirection is horizontal. At the same time I
    want to display an alternate background color on the every second item.

    However, the number of items in the list is not always the same, and since
    ..NET seems to pick (for himself) what number of items to display in each
    column, I can't control how it's going to come out in the browser.

    To better illustrate (with the ItemTemplate's backgroundcolor as Gray, and
    the AlternatingItemTemplate's backgroundcolor as Silver:

    1. A list with 9 elements would display like this:

    Gray Gray Gray
    Silver Silver Silver
    Gray Gray Gray

    2. However, a list with 10 element would display like this:

    Gray Gray Silver
    Silver Silver Gray
    Gray Gray Silver
    Gray

    What I'm asking is: is it possible to detect when the datalist is actually
    starting a new column, so I can override or something? Or is there a better
    way to fix this?

    Any help or assistance is much appreciated. Thanks!
    --
    Regards,

    Frank :)
     
    Frank, Sep 29, 2004
    #1
    1. Advertising

  2. I think the best way would be to make your own event handler for
    OnItemDataBound event and create TRs & TDs as needed...

    --
    RobertK
    { Clever? No just smart. }


    "Frank" <> wrote in message
    news:...
    > Hi all,
    >
    > I'm having this challenge:
    > I have a datalist, which I display in more than one column
    > (RepeatColumns="3") and RepeatDirection is horizontal. At the same time I
    > want to display an alternate background color on the every second item.
    >
    > However, the number of items in the list is not always the same, and since
    > .NET seems to pick (for himself) what number of items to display in each
    > column, I can't control how it's going to come out in the browser.
    >
    > To better illustrate (with the ItemTemplate's backgroundcolor as Gray, and
    > the AlternatingItemTemplate's backgroundcolor as Silver:
    >
    > 1. A list with 9 elements would display like this:
    >
    > Gray Gray Gray
    > Silver Silver Silver
    > Gray Gray Gray
    >
    > 2. However, a list with 10 element would display like this:
    >
    > Gray Gray Silver
    > Silver Silver Gray
    > Gray Gray Silver
    > Gray
    >
    > What I'm asking is: is it possible to detect when the datalist is actually
    > starting a new column, so I can override or something? Or is there a

    better
    > way to fix this?
    >
    > Any help or assistance is much appreciated. Thanks!
    > --
    > Regards,
    >
    > Frank :)
     
    Robert Koritnik, Sep 30, 2004
    #2
    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. Nalaka

    gridView on more than one column

    Nalaka, Jan 3, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,572
    =?Utf-8?B?RWx0b24gVw==?=
    Jan 4, 2006
  2. Chuck Foster
    Replies:
    4
    Views:
    427
  3. Merciadri Luca
    Replies:
    4
    Views:
    834
  4. Steven D'Aprano
    Replies:
    0
    Views:
    116
    Steven D'Aprano
    Dec 23, 2013
  5. Replies:
    3
    Views:
    98
    Gary Herron
    Dec 23, 2013
Loading...

Share This Page