来自gridview列的过期日期提醒 [英] Expired date alert from gridview column

查看:60
本文介绍了来自gridview列的过期日期提醒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个编码的想法,用于来自gridview的红色过期日期警报。 GridView列名称日期和数据类型日期。我需要这个代码asp.net网站。我怎么能正确地做到这一点。我可以用定时器时钟吗?我试过这个



我尝试过:



I need a coding idea for for Expired Date alert by Red color from a gridview. GridView column name 'Date' and data type 'date'. i need this for code asp.net website. how can i do this correctly. Can i do this with timer clock?? i've tried this one

What I have tried:

protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
        DateTime date = Convert.ToDateTime(GridView1.Rows[i].Cells[3].Text);
        if (date < DateTime.Now)
        {
            GridView1.Rows[i].Cells[3].BackColor = System.Drawing.Color.Red;
        }
    }
}

推荐答案

你应该刷新 GridView 数据定期使用计时器



如何使用AJAX TimerEverything技术自动刷新GridView [ ^ ]

使用计时器自动刷新Asp.Net Ajax中的GridView [ ^ ]



在OP澄清后更新解决方案:

You shall Refresh the GridView data on a periodic manner using Timer

How to refresh GridView automatically using AJAX TimerEverything Technical[^]
Auto Refresh Update GridView In Asp.Net Ajax With Timer[^]

updated solution after OP's clarification:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           if (e.Row.RowType == DataControlRowType.DataRow)
           {
             DateTime dt =  DateTime.ParseExact(e.Row.Cells[1].Text, "dd-MMM-yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
             if (dt < DateTime.Now)
                   e.Row.Style.Add("background-color", "red");
           }
       }


这篇关于来自gridview列的过期日期提醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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