Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 30, 2011 08:38 AM by Qin Dian Tang - MSFT
Mar 28, 2011 03:53 PM|LINK
Is there any way to alternate the color of rows in a databound checkboxlist??? I have googled this for quite some time and am unable to come up with anything helpful....
I have three checkboxlists and I want to alternate the row color in each checkboxlist with white and grey. Suggestions?! Any help would be greatly appreciated!!!!
Mar 28, 2011 04:47 PM|LINK
You can add background color attribute for the ListItem
<asp:CheckBoxList runat="server" ID="CheckBoxList1"
protected void CheckBoxList1_PreRender(object sender, EventArgs e)
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
if (i % 2 != 0)
Mar 28, 2011 05:43 PM|LINK
That code works! :) EXCEPT, one more thing - how do I get the color to extend the full length of the row, not just the length of the text in that particular row?
Mar 30, 2011 08:38 AM|LINK
You can only change the color of CheckBoxList in the place of itself. The whole row you mean I guess it is not the part of CheckBoxList, so you cannot change it with setting anything in CheckBoxList. You can use CheckBox in a Repeater or DataList, then bind
it and set the style to the Item in Repeater or DataList as a workaround.