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

第一步:这样写Sql语句:

selecttop5PK_Rntol_ID,Title,RenoDate,Promulgator,Flag=case
whengetdate()-RenoDate<5then'1'
else'0'
end
fromesintypzb.T_Info_RntolwhereRenoKind=@typeorderbyRenoDatedesc

第二步:

在DataGrid的DataBound()方法里面:

///<summary>
///根据日期的多少,决定是否显示new图标
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
privatevoidwgrd_Info_ItemDataBound(objectsender,System.Web.UI.WebControls.DataGridItemEventArgse)
{
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;<imgsrc=http://www.cnblogs.com/Images/new.gif>";
}
}
}

posted @ 2008-10-27 12:29  剑者  阅读(156)  评论(0编辑  收藏  举报