在GridView中为新工程图显示的标志 [英] Flag to be Displayed for New Drawings in GridView

查看:106
本文介绍了在GridView中为新工程图显示的标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个GridView,其中一栏是Drawigns&发布日期.
现在,我想要的是在图纸发布之前显示新标志" ,该图纸可以发布到最近2天.


谁能帮我解决这个问题?

Hi,



I have a GridView , in that one of the column is Drawigns & Release Date.
Now, what i want is i want to display "New Flag" before the Drawing which are released upto last 2 days.


can any one help me how to solve this issue

推荐答案


能否请您检查下面的代码.我没有编译代码.

Hi
Can you please check the below code. I didn''t compile the code.

protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
         if (e.Row.RowType == DataControlRowType.DataRow)
         {
             DataRow row = ((DataRowView)e.Row.DataItem).Row;
            if(row.Field<string>("Column1").ToString().Equals("Your Value")
          {
                           e.Row.Cells["NewColumn"].Text = "Flag";
          }
           }
      }


在上面的代码中添加了一些更改.比较发行日期和当前日期(如果其小于2,则将其标记为new.).

Adding a little change to the above code.. Compare the release date and current date if its less than 2 then the flag as new..

protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DateTime today = DateTime.Now;
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRow row = ((DataRowView)e.Row.DataItem).Row;
            if(Convert.ToDateTime(e.Row.Cells["Column1"])-today < 2)
            {
                    e.Row.Cells["NewColumn"].Text ="Flag";
            }
        }
    }


这篇关于在GridView中为新工程图显示的标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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