views:

398

answers:

1

I would like to add hyperlinks dynamically to the cell of a specific column in my datatable. Currently my code is only showing the text.

Here is my code:

SqlConnection conn = null;
string sSQL = "";
string connString = "Datasourceetc";

sSQL = "SELECT TEST_ID FROM TEST_TABLE";

SqlDataAdapter sda = new SqlDataAdapter(sSQL, conn);

DataTable dt = new DataTable();

sda.Fill(dt);

foreach (DataRow row in dt.Rows)
{
  row["TEST_ID"] = "<a href='www.google.com'>Google</a>"; //<----I only see the text!
}

GridView1.DataSource = dt;

GridView1.DataBind();

Thank you

+1  A: 

If you're doing this through an asp:BoundField you'll want to set the HtmlEncode property to false.

CAbbott