Repeater control alternating backgrounds

October 8, 2007 20:02 by Dominick
Here's an easy way to have an alternating background color with a Repeater control. There's no "AlternatingItemStyle" like in other data list controls, but this does this trick with a couple lines of code.


protected void OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
  if (e.Item.ItemType == ListItemType.AlternatingItem)
   {
     ((HtmlTableRow)e.Item.FindControl("Row")).BgColor = "silver";
   }
}



kick it on DotNetKicks.com





Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading