using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class topnews : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = oper.dt("select top 4 * from news order by nid desc");
        gdvnews.DataSource = dt;
        gdvnews.DataKeyNames = new string[] { "nid" };
        gdvnews.DataBind();
    }
    protected void gdvnews_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink hpl = (HyperLink)e.Row.FindControl("HyperLink1");
            if (hpl.Text.Length >= 18)
            {
                hpl.Text = hpl.Text.Substring(0, 17) + "...";
            }
        }
    }
}
