Hi RichardSa,
Check this example. Now please take its reference and correct your code.
HTML
<asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="false"
OnRowDataBound="OnRowDataBound">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name"></asp:BoundField>
</Columns>
</asp:GridView>
<style type="text/css">
#gvDetails a {
cursor: pointer;
text-decoration: none;
color: black;
}
</style>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Name");
dt.Rows.Add("Prospectus");
dt.Rows.Add("Brochure");
gvDetails.DataSource = dt;
gvDetails.DataBind();
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = string.Format("<b><a target='_blank' href='https://www.dictionary.com/browse/{0}'>{0}</a></b>", e.Row.Cells[0].Text.Trim());
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As Data.DataTable = New Data.DataTable()
dt.Columns.Add("Name")
dt.Rows.Add("Prospectus")
dt.Rows.Add("Brochure")
gvDetails.DataSource = dt
gvDetails.DataBind()
End If
End Sub
Protected Sub OnRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(0).Text = String.Format("<b><a target='_blank' href='https://www.dictionary.com/browse/{0}'>{0}</a></b>", e.Row.Cells(0).Text.Trim())
End If
End Sub
Screenshot