How to add a Hyperlink to a dynamic gridview column
<p>I have an issue hope someone can help.</p>

<p>I have a dynamic gridview. I need to have a hyperlink on gridview column. These hyperlink should open a popup to display certain data on clicking.</p>

<p>I tried this by having a dynamic template field . But even on binding the data , I'm unable to get the hyper link for the column. I'm able to get the data but not the hyperlink.</p>

<p>This is the HyperLinkTemplate class which is implementing ITemplate.</p>

<p>public class HyperLinkTemplate : ITemplate
{
    private string m_ColumnName; 
    public string ColumnName
    {
        get { return m_ColumnName; }
        set { m_ColumnName = value; }
    } </p>

<pre><code>public HyperLinkTemplate()
{
    //
    // TODO: Add constructor logic here
    //
}
public HyperLinkTemplate(string ColumnName)
{
    this.ColumnName = ColumnName;

}

public void InstantiateIn(System.Web.UI.Control ThisColumn)
{
    HyperLink HyperLinkItem = new HyperLink();
    HyperLinkItem.ID = "hl" + ColumnName;
    HyperLinkItem.DataBinding += HyperLinkItem_DataBinding;
    ThisColumn.Controls.Add(HyperLinkItem);

}

private void HyperLinkItem_DataBinding(object sender, EventArgs e)
{
    HyperLink HyperLinkItem = (HyperLink)sender;
    GridViewRow CurrentRow = (GridViewRow)HyperLinkItem.NamingContainer;
    object CurrentDataItem = DataBinder.Eval(CurrentRow.DataItem, ColumnName);
    HyperLinkItem.Text = CurrentDataItem.ToString();

}
</code></pre>

<p>} </p>
