原创  想实现日期为当天的时候,显示的日期颜色跟其他的不同 收藏

private void Page_Load(object sender, System.EventArgs e)
{
for(int i=0; i < DataGrid1.Items.Count; i++)
{  
if(Convert.ToDateTime(DataGrid1.Items[i].Cells[0].Text).ToShortDateString()==System.DateTime.Now.ToShortDateString())
{
DataGrid1.Items[i].Cells[0].ForeColor = System.Drawing.Color.Red;//假设第一列是你的日期列
}
}
}

第二种方法,是使用模板列

<asp:TemplateColumn>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,"时间").ToString()==DateTime.Now.ToString()?"<font color=red"+DataBinder.Eval(Container.DataItem,"时间").ToString()+"</font>":DataBinder.Eval(Container.DataItem,"时间").ToString() %>
</ItemTemplate>
</asp:TemplateColumn>

发表于 @ 2006年03月26日 23:30:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:怎样在浏览器状态栏文字显示用户信息 | 新一篇:JS常用的一些判断输入验证

  • 发表评论
  • 评论内容:
  •  
Copyright © levin9
Powered by CSDN Blog