我刚开始学C#,有个简单新闻程序,想让新闻列表中当天的标题后面加一个new的小图标,该怎么实现呢?
我想过用日期做判断,如果是当天的新闻,就显示new,否则不显示。或者是用cookie判断,如果没有点击过,则显示new,如已经看过,则不显示.
可是具体怎么写我实在不行,现在水平只能翻着书读代码,
只好把代码贴上来,希望有好心的达人帮我改改,我好学习研究一下.
paper_xwsd.ascx文件------------------------------------------------
<%@ Control Language= "C# " AutoEventWireup= "true " CodeFile= "paper_xwsd.ascx.cs " Inherits= "paper_xwsd " %>
<asp:GridView ID= "paperviewtj " runat= "server " AutoGenerateColumns= "False " ShowHeader= "False "
Width= "388px " BorderStyle= "None ">
<Columns>
<asp:TemplateField>
<ItemTemplate>
· <a href= "papernews.aspx?paperid= <%# DataBinder.Eval(Container.DataItem, "PaperId ")%> "> <%#returncutstr(DataBinder.Eval(Container.DataItem, "papertitle ").ToString())%> </a>
</ItemTemplate>
<ItemStyle HorizontalAlign= "Left " VerticalAlign= "Middle " Width= "250px " BorderStyle= "None " />
</asp:TemplateField>
</Columns>
</asp:GridView>
paper_xwsd.ascx.cs内容------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class paper_xwsd : System.Web.UI.UserControl
{
protected string returncutstr(string papertitle)
{
if (papertitle.Length > 14)
{
return papertitle.Substring(0,14) + "... ";
}
else
{ return papertitle; }
}
protected void Page_Load(object sender, EventArgs e)
{
dbcom.Dbselect( "select top 5 * from PaperNews where Smallclass= '60 ' and onoff= 'ye