阅读内容 

在DataGrid里面根据日期的不同显示new图标

[日期:2005-11-19] 来源:易书网  作者:佚名 [字体: ]

第一步:这样写Sql语句:

select  top 5  PK_Rntol_ID,Title,RenoDate,Promulgator,Flag=case
when getdate() - RenoDate < 5 then '1'
else '0'
end
from esintypzb.T_Info_Rntol where RenoKind= @type order by RenoDate desc

第二步:

在DataGrid的DataBound()方法里面:

/// <summary>
  /// 根据日期的多少,决定是否显示new图标
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void wgrd_Info_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  {
   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
   {
    if(e.Item.Cells[5].Text == "1")
    {
     e.Item.Cells[1].Text = e.Item.Cells[1].Text + "&nbsp;<img src=../../Images/new.gif>"; 
    }
   }
  }

阅读:
录入:

推荐 】 【 打印
相关新闻      
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:
Advertisement
内容查询


Advertisement