Reputation: 1929
I was having difficulties trying to change the background or foreground color dynamically behind code in c#. The checkbox is inside an itemtemplate, where the itemtemplate is inside a gridview. The gridview is bound with data, so there are many checkboxes, what i need to do is change the color of spesific checkboxes.
Upvotes: 0
Views: 7023
Reputation: 411
write this following code inside RowDataBound event of GridView.Find that checkBox ,after that you can access that checkBox's properties
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox chk = (CheckBox)e.Row.FindControl("checkBox1");
chk.BackColor = System.Drawing.Color.Black;
}
Upvotes: 1