一个控件在今天的半个小时不显示,半个小时之后显示别一个控件是今天的前一天不显示ASP.NET代码现在写操作了半天的datetime现在都有点头疼了请高手解决一下这个问题急 在线等,完成问题后再加分!!!!!!
解决方案 »
- 图片上传(主要是路径问题)
- 跨域共享session有什么好的解决方案
- 安全控件,怎么做?
- 很简单的DropDownList二级联动,请有耐心的高手看看
- oa功能
- 新手!~~~就三十分了 大家可怜可怜吧
- 求高手指教如何取出数据表当中所有的列名称和类型?(急)
- 动软生成代码问题ACCESS数据库(解决马上给分 在线等)
- 如何用图片代替asp:button
- 设置aspx网页背景图象时,怎么不能用虚拟目录下的jpg文件?
- SQL2000只能浏览到C盘,求助
- 导入Excel得到的DataTable没有像Excel文件里的行数主键,如何在导入Excel时候得到行数或者让Datatable拥有自增为1的id主键
AddHous(0.5);
记录开始时间
这个列表里有一个生效时间
比如生效时间是:2010-6-7 19:20:00
那么再跟当前的时间做比较
看看是不是在30分钟之内(2010-6-7 19:50:00这个时间是显示的----这个时间段之前是不显示的)
如果在的话GridView里的第一列不显示
不知道我说清楚了没
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
//当前时间
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;
}
}这是代码 该怎么修改啊
DateTime ts2 = DateTime.Parse("");
TimeSpan ts = ts1.Subtract(ts2).Duration();
Hours:返回用小时计算的TimeSpan值
Milliseconds:返回用毫秒计算的TimeSpan值。
Minutes:返回用分钟计算的TimeSpan值。