动态改变复选框的背景\\前景,颜色,里面的GridView一个ItemTemplate内 [英] dynamically change checkbox background\foreground-color which is inside an itemtemplate inside gridview
本文介绍了动态改变复选框的背景\\前景,颜色,里面的GridView一个ItemTemplate内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是有困难的尝试动态更改背景或前景颜色背后code在C#。复选框是一个ItemTemplate,在ItemTemplate中是一个gridview里面里面。在GridView绑定的数据,所以有很多复选框,我需要做的是改变spesific复选框的颜色。
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.
推荐答案
写这篇以下$ C $ GridView.Find的RowDataBound事件的复选框,以后您可以访问该复选框的属性C内
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;
}
这篇关于动态改变复选框的背景\\前景,颜色,里面的GridView一个ItemTemplate内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文