更改GridView的背景颜色 [英] Change background color of a GridView

查看:90
本文介绍了更改GridView的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我有一个超过200行的GridView.我想更改参考号重复的背景颜色.我在后面的代码中将数据绑定到GridView.
你是怎么做到的?

我们将不胜感激您的帮助:-)

Hi all. I have a GridView that has over 200 rows. I want to change the background color where my Reference number is duplicates. I bind the data to my GridView in my code behind.
How do you do it?

Your help would be appreciated :-)

推荐答案

如有可能,更改查询以使用group by包括出现次数.
然后您可以直接使用RowDataBound事件
Change your query to include count of occurrence using group by, if possible.
Then you can directly use RowDataBound event
If (e.Row.DataItem("occurrence") > 1) Then
 e.Row.BackColor = Drawing.Color.Red
End If  



否则,您需要遍历各行,并检查它们是否重复并相应地设置BackColor.



Otherwise, you need to loop through rows, and check whether it is duplicate or not and set the BackColor accordingly.


这篇关于更改GridView的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆