This is a migrated thread and some comments may be shown as answers.

Alternating color of each entry?

1 Answer 119 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 23 Sep 2010, 08:44 PM
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?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Sep 2010, 07:59 AM
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.
Tags
ListBox
Asked by
Steve
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or