根据时间更改GridView单元格颜色 [英] Change GridView cell color based on Time

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

问题描述

大家好,

我的页面具有Gridview和Servertimer控件.

如果服务器时间已过,则Gridview单元格的颜色应更改.

例如,我的服务器时间"是7.35 AM
如果单元格"值为"7.31.00",则表示它与ServerTime相比已经过去,因此我需要更改其颜色为红色".
否则我会是相同的卡其色.

任何帮助都将非常有用.

谢谢,
Vidhya.

Hello All,

My Page has a Gridview and a Servertimer control.

Gridview cells color should change if server time elapses.

Say for example, My ServerTime is 7.35 AM
If my Cell value is "7.31.00" means it elapsed when compared to ServerTime, so I need its color to change "Red".
else I would be in same Khaki color.

Any help would be much useful.

Thanks,
Vidhya.

推荐答案

嗨 Vidhya,

请使用以下内容:
Hi Vidhya,

Please use following:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string time= e.Row.Cells[0].Text;
            string[] names = new string[] { "170", "171" };
            if (time >= DateTime.Now.Tostring("HH:mm:ss"))
            {
                e.Row.Cell[0].BackColor = "LightBlue";
            }
        }
    }



谢谢,
Imdadhusen



Thanks,
Imdadhusen


嗨Imdadhusen,

感谢您的答复.

反正我们可以用Javascript做到吗?

问候,
Vidhya.
Hi Imdadhusen,

Thanks for your reply.

Is there anyway we can do it in Javascript?

Regards,
Vidhya.


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

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