Click here to Skip to main content
14,733,301 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using repeater in my code and how can i give diffrent colour for different status
Posted
Comments
member60 27-Feb-12 7:29am
   
be sure first whether you are using gridview or repeater ?

private void rptData_ItemDataBound(object source,
                                   RepeaterCommandEventArgs e)
{
   if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType !=
      ListItemType.AlternatingItem)
      return;

   LinkButton btn = (LinkButton)e.Item.FindControl("btnDelete");
HiddenField hdnStatus = (HiddenField )e.Item.FindControl("hdnStatus ");

   if(hdnStatus.Value="True")
{

based on status u can change here 
btn.Color=??
}
}
   
Hi,


I assume you mean giving different items different colors in the repeater, then I would use the ItemDataBound(object sender, RepeaterItemEventArgs e), and then find the right control with e.Item.FindControl(..

Regards
Joachim
   
Hi, On ItemDataBound event of Repeater, change ForeColor of Label as you want.

First, Find Label Control using FindControl() function then set ForeColor property to Color. You will find your solution.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900