using System;
using System.Data;
using System.Configuration;
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;
/// <summary>
/// MyTemplate 的摘要说明
/// </summary>
public class MyTemplate:ITemplate
{
#region ITemplate 成员
public void InstantiateIn(Control container)
{
Literal lbl = new Literal();
lbl.DataBinding += new EventHandler(lbl_DataBinding);//关键在这里
container.Controls.Add(lbl);
}
#endregion
private void lbl_DataBinding(object sender, EventArgs e)
{
Literal lbl = (Literal)sender;
GridViewRow objContainer = (GridViewRow)lbl.NamingContainer;
DataRowView row = objContainer.DataItem as DataRowView;
if (row != null)
{
lbl.Text = "<a href='" + row[0].ToString() + "'>" + row[0].ToString() + "</a>";
}
}
#region ITemplate 成员
#endregion
}