Alternating color of each entry?

2 posts, 0 answers
  1. Steve
    Steve avatar
    14 posts
    Member since:
    Jul 2005

    Posted 23 Sep 2010 Link to this post

    Is there an easy way to alternate the color of each 'row' in a listbox, like you can in a grid?  maybe i'm just tired, and missing it.  are there examples out there?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2010 Link to this post

    Hello Steve,


    Here is the sample code to get it worked.

    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (RadListBoxItem item in RadListBox1.Items)
        {
            if (item.Index % 2 == 0)
            {              
                item.CssClass = "myClassItem";
            }
            else
            {
                item.CssClass = "myClassAlterItem";
            }
        }
    }


    CSS:
     
    <style type="text/css">
        .myClassItem
        {
            background-color: LightGray;
        }
        .myClassAlterItem
        {
            background-color: Azure;
        }
    </style>



    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top