title: Adding a hyperlink column to a 'GridView' dynamically (server-side)
body: <p>I have an <strong>ASP.NET</strong> application that reads an XML source and creates columns in a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview%28v=vs.110%29.aspx" rel="nofollow">GridView</a>. This same XML source is used to create columns in a <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx" rel="nofollow">DataTable</a>. The application populates the <code>DataTable</code> and then binds the <code>DataTable</code> to the <code>GridView</code> using server-side code.</p>
  
  <p>Now I want to display a hyperlink in the <code>GridView</code> and am not sure how to do it. (Note that the application is not making use of the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound(v=vs.110).aspx" rel="nofollow">RowDataBound</a> event.)</p>
  
  <p>Here is what I have thus far:</p>
  
  <pre class="lang-cs prettyprint-override"><code>foreach (XmlNode columnNode in columnNodes)
  {    
      dc = new DataColumn(columnNode.Attributes["ColumnName"].Value,
          Type.GetType("System.String"));
      dt.Columns.Add(dc);
  
      boundField = new BoundField();
      boundField.HeaderText = columnNode.Attributes["ColumnDisplayName"].Value;
      boundField.DataField = columnNode.Attributes["ColumnName"].Value;
      boundField.SortExpression = columnNode.Attributes["ColumnName"].Value; 
      grdView.Columns.Add(boundField);    
  } 
  </code></pre>
  
  <p>where <code>dt</code> is a <code>DataTable</code> and <code>grdView</code> is a <code>GridView</code>.</p>