title: Link in a DataRow (Datatable)
body: <p>I'm building a DataTable dynamically and I'm trying to add a "link" in the DataRow(s) that I'm adding to the DataTable. The DataTable is bound to a GridView after it's creation.</p>
  
  <p>Something like that :</p>
  
  <pre><code>   DataTable dataTable = new DataTable();
     foreach (Item item in items)
      {
          DataRow row = dataTable.NewRow();
          dataTable.Columns.Add(new DataColumn("col"));
  
          row["col"] = "&lt;a href='http://www.google.com'&gt;Link here&lt;/a&gt;";
  
          dataTable.Rows.Add(row);
  
      }
  </code></pre>
  
  <p>Then I bind it to a GridView :</p>
  
  <pre><code>        &lt;asp:GridView ID="grdView" Runat="server" border="0" EnableViewState="true" style="width:100%;"
              AutoGenerateColumns="true" AllowPaging="false" PagerSettings-Visible="false" 
              ShowHeader="true" ShowFooter="true" CellPadding="0" CellSpacing="0"
              Visible="True"&gt;
          &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>But the HTML in the Column is encoded when I bind it to the GridView.
  Is there a way to add a HyperLink object there or something like that?</p>
  
  <p>P.S. It's not in the example but the columns are added dynamically (it means that I don't know before the rendering how many columns I'll have)</p>
  
  <p><strong>UPDATE #1</strong></p>
  
  <p>I have access to the GridView when I create the columns.
  I was able to do something like that :</p>
  
  <pre><code>    dataTable.Columns.Add(new DataColumn("col"));
  
      BoundField bf = new BoundField();
      bf.HtmlEncode = false;
      bf.DataField = "col";
      grd.Columns.Add(bf);
  
     row["col"] = "&lt;a href='http://www.google.com'&gt;Link here&lt;/a&gt;";
  </code></pre>
  
  <p>But it displays 2 coloumns "col"...</p>
  
  <p><strong>UPDATE #3 :</strong>
  I used a DataGrid instead. It doesn't encode HTML when inserted in "plain text" in the data rows.</p>