在gridview中,如何根据某一字段的不同的值,显示不同的颜色 比如这个字段的值是1,那么这一行就显示红色,字段的值是2,相应的行就显示黄色.用VB.NET实现 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将该字段设置为模板列,比如Label_f,在RowDataBound事件中: Label Label_f= (Label)(e.Row.FindControl("Label_f")); if (Label_f!= null) { if(Label_f.text=="1") { e.Row.BackColor = Color.Red; } } 在绑定的时候写.gridview_OnDataBound(){ Label label1 = e.Item.FindControl("lable1") as Label; Label label2 = e.Item.FindControl("lable2") as Label; if(lable1.Text == "1") { label2.ForeColor = "red"; }else if(lable1.Text == "2"){ label2.ForeColor = "blue"; } }大概是这样,给你个思路,可能语句写得不对。 无比灵异的啊!!!!!!!!!! 求ASP.NET自助建站系统源代码 关于asp.net单线程 有做过的兄弟请进 asp.net C#语言求助 哪里有微软官方论坛源码 在线等待,如何跳转页面! 喜欢用VB.NET的人有福啦!--- 终于找到一个能用的VBCommenter和大家分享,拥有类似于C#的自定义智能感知提示功能的东东。 关于梅花雨控件3的时间修改问题 如何能最简实现全文检索? 无法打开*.aspx ??? 为什么找不到IIS了啊,求救???? 在ASP。NET 2。0 中的URL映射(URL Mapping)
Label Label_f= (Label)(e.Row.FindControl("Label_f"));
if (Label_f!= null)
{
if(Label_f.text=="1")
{
e.Row.BackColor = Color.Red;
}
}
gridview_OnDataBound(){
Label label1 = e.Item.FindControl("lable1") as Label;
Label label2 = e.Item.FindControl("lable2") as Label;
if(lable1.Text == "1") {
label2.ForeColor = "red";
}else if(lable1.Text == "2"){
label2.ForeColor = "blue";
}
}大概是这样,给你个思路,可能语句写得不对。