如何在ASP.NET C#中更改Gridview单元格的背景颜色 [英] How to change the background color of Gridview cell in asp.net c#

查看:620
本文介绍了如何在ASP.NET C#中更改Gridview单元格的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,大家好!

我正在做School Project.

我有一个带有学生成绩的学生数据库.

我已经在Gridview中显示了此数据...工作正常.

我的数据库字段为

名称类别部分结果百分比
========================================
阿伦10 A Pass 89
Kishore 10 A Fail 95
Sandeep 10 B失败29


因此,我的要求"是在Gridview中显示任何失败的地方,它必须将单元格的背景颜色更改为红色.


请帮助我,该怎么做? ?

谢谢.

Dear Friends, Good Day to all of u.

am working on School Project.

I have a Student Database with Student Marks.

i have displayed this data in Gridview...it working fine.

I have Database Fields as

Name Class Section Result Percentage
===========================================
Arun 10 A Pass 89
Kishore 10 A Fail 95
Sandeep 10 B Fail 29


So, My Requirement is whereever fail is displayed in Gridview it must change the background color of cell to red.


Please help me, How to do this ? ?

Thanks.

推荐答案



您可以在gridview的 ondatabound 事件中更改gridview的单元格背景色.

浏览链接

http://highoncoding.com/Articles/180_Changing_GridView_Column_Color.aspx [根据系统日期更改GRIDVIEW的单元格颜色 [ ^ ]


You can change the gridview''s cell backcolor in ondatabound event of the gridview.

Go through the links

http://highoncoding.com/Articles/180_Changing_GridView_Column_Color.aspx[^]

change cell color of GRIDVIEW based on system date[^]




您需要检查该值是否小于 OnRowDataBound [ ^ ]事件.要更改该单元格的颜色,您只需使用

Hi,

You need to check if the value is less then the passing marks in OnRowDataBound[^] event of the gridview. And to change the color of that cell you can simply use

args.Row.Cells[columnindex].BackColor = Your Color;



希望对您有帮助,
谢谢



Hope it helps you,
Thanks


这篇关于如何在ASP.NET C#中更改Gridview单元格的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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