分类广告


推荐文章

  • 没有找到任何内容!
您当前的位置:中国站长下载网络编程ASP专区 → 文章内容

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

  • 作者:佚名    来源:不详    发布时间:2005-12-31 11:44:02
  • 字体大小:
 

第一步:这样写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=http://zz.315top.com/Images/new.gif>"; 
    }
   }
  }