title: How to add a Hyperlink to a dynamic gridview column
body: <p>I have an issue hope someone can help.</p>
  
  <p>I have a dynamic <code>Gridview</code>. I need to have a <code>hyperlink</code> 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 <code>HyperLinkTemplate</code> class which is implementing <code>ITemplate</code>.</p>
  
  <pre><code>public class HyperLinkTemplate : ITemplate
  {
      private string m_ColumnName;
      public string ColumnName
      {
          get { return m_ColumnName; }
          set { m_ColumnName = value; }
      }
  
      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>