I have a grid view. Datatable is the data source.
I am looking for solution where I can add links to gridview column. But not by creating hyperlink field or not even want to play with designer part.
This is a common gridview, which will get dynamic data including columns.
Not necessary every datasource will have 'Name' column which is my target as hyper link.
I am able to generate <a href='...'>text</a> but it is displaying as is in gridview.
HTML block :
<asp:GridView ID="gvCommonDashboard" runat="server">
</asp:GridView>
Code Behind :
foreach (DataRow dr in dt.Rows)
{
string name = Convert.ToString(dr["Name"]);
string url = SPContext.Current.Web.Url + listName + "/" + name;
dr["Name"] = string.Format("<a href='" + url + "'>" + name + "</a>");
}
dt.AcceptChanges();
gvCommonGrid.DataSource = dt;
gvCommonGrid.DataBind();
gvCommonGrid.Visible = true;