如何在Gridview中应用颜色代码 [英] how to apply Color Code in Gridview

查看:69
本文介绍了如何在Gridview中应用颜色代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

在我的Webform上,我有一个Gridview,下面是我的列颜色更改代码.

Dear Frnds ,

On my Webform I have a Gridview, and below is my code for column color change.

if (getDate2 < dt3)
            {
                item.Cells[4].BackColor = Color.Green;
            }
            else
            {
                item.Cells[4].BackColor = Color.Red;
            }

            if (getDate2 > dt4)
            {
                item.Cells[5].BackColor = Color.Red;
            }
            else
            {
                item.Cells[5].BackColor = Color.Green;
            }



请您能建议我如何为此提供颜色代码.我需要浅色的绿色和红色.

例如#00FF00(浅绿色)
##FF6666(浅红色)

我在代码中需要上面的颜色.请帮帮我.


谢谢,



Please can u Suggest me how to give color code for this. I need a light color for green and RED.

for Example # 00FF00 (Light Green)
# #FF6666 (Light RED)

i need this above colors in that code. please help me.


THANKS,

推荐答案


你可以试试这个
Hi,
You can try this
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow )
       {
           if (e.Row.Cells[1].Text == "1")
           {
               e.Row.Cells[1].BackColor = Color.Red;
           }
       }
   }


最好的问候
M.Mitwalli


Best Regards
M.Mitwalli


您好,您可以使用此代码
you can use this code
GridView1.Rows[1].Cells[1].BackColor = System.Drawing.Color.Red;


在下面的链接中是颜色列表:

ASP.NET中的颜色


and in below link is list of colors :

Colors in ASP.NET




使用以下代码,您可以将颜色代码转换为颜色

Hi,

using Following code u can convert color code to color

Color clr = ColorTranslator.FromHtml("#FFFF33");



希望对你有帮助
祝你好运
快乐编码:)



hope this help u
best Luck
happy Coding :)


这篇关于如何在Gridview中应用颜色代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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