一个控件在今天的半个小时不显示,半个小时之后显示别一个控件是今天的前一天不显示ASP.NET代码现在写操作了半天的datetime现在都有点头疼了请高手解决一下这个问题急 在线等,完成问题后再加分!!!!!!

解决方案 »

  1.   

    AddDays(-1);
    AddHous(0.5);
    记录开始时间
      

  2.   

    是一个GridView第一列和第二列有两个按钮 
    这个列表里有一个生效时间
    比如生效时间是:2010-6-7 19:20:00
    那么再跟当前的时间做比较
    看看是不是在30分钟之内(2010-6-7 19:50:00这个时间是显示的----这个时间段之前是不显示的)
    如果在的话GridView里的第一列不显示
    不知道我说清楚了没
      

  3.   

    C#比较两个日期的大小using System;
    using System.Collections;public class MyClass
    {
    public static void Main()
    {
    DateTime dt1 = DateTime.Parse("2006-04-01");
    DateTime dt2 = DateTime.Parse("2006-05-01");TimeSpan ts = dt2.Subtract(dt1);
    Console.WriteLine(ts.TotalDays);
    Console.ReadLine();
    }}System.TimeSpan diff1 = date2.Subtract(date1);
    此方法可以到具体的相差值直接将两个DateTime相减,结果就是一个TimeSpan,从而可以取到TimeSpan的days等各个属性如果简单的比较大小,这样就可以了
    DateTime.Compare(t1, t2) >    0DateTime.Compare(t1,t2),方法获取一个数字,果之小于0,则t1<t2,大于0,则t1>t2, 等于0,则t1=t2
     
      

  4.   


    //当前时间
            DateTime dt = DateTime.Now ;
            if (e.Row.RowType==DataControlRowType.DataRow)
            {
                ((Button)e.Row.Cells[0].FindControl("butdel")).Style.Add(HtmlTextWriterStyle.Color, "red");
                ((Button)e.Row.Cells[0].FindControl("butdel")).Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
                if (e.Row.Cells[3].Text == "A款")
                {
                    //((Button)e.Row.Cells[0].FindControl("butdel")).Visible = false;
                    e.Row.Visible = false;
                }
                if (e.Row.Cells[3].Text == "B款")
                {                DateTime dtc10 = Convert.ToDateTime(e.Row.Cells[10].Text);
                    if (dt < dtc10)
                    {
                        if (dt.Hour > dtc10.AddHours(-30).Hour)
                        {
                            ((Button)e.Row.Cells[0].FindControl("butdel")).Visible = false;
                        }
                        else
                        {
                            ((Button)e.Row.Cells[0].FindControl("butdel")).Visible = true;
                        }
                    }
                    else
                    {
                        ((Button)e.Row.Cells[0].FindControl("butdel")).Visible = false;
                    }
    }这是代码   该怎么修改啊
      

  5.   

    DateTime ts1 = DateTime.Parse("");
    DateTime ts2 = DateTime.Parse("");
    TimeSpan ts = ts1.Subtract(ts2).Duration();
    Hours:返回用小时计算的TimeSpan值 
    Milliseconds:返回用毫秒计算的TimeSpan值。 
    Minutes:返回用分钟计算的TimeSpan值。