第一步:这样写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+" <imgsrc=../../Images/new.gif>";
}
}
}