Hi Mehram,
Check this example. Now please take its reference and correct your code.
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name Detail" ItemStyle-Width="250" />
</Columns>
</asp:GridView>
Namespaces
C#
using System.Data;
using System.Text.RegularExpressions;
VB.Net
Imports System.Data
Imports System.Text.RegularExpressions
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Rows.Add("MUHAMMAD SHAKIR / MUHAMMAD YAKOOB (0002-000593) / JUNAGARH WALA");
dt.Rows.Add("MUHAMMAD SHAKIR / MUHAMMAD YAKOOB (0002-000594) / JUNAGARH WALA");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = Regex.Replace(e.Row.Cells[0].Text, "\\([^()]*\\)", delegate (Match match)
{
return string.Format("(<a href='Details.aspx?Id={0}'>{0}</a>)", match.Value.Replace("(", "").Replace(")", ""));
}, RegexOptions.IgnoreCase);
}
}
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 DataTable = New DataTable()
dt.Columns.Add("Name")
dt.Rows.Add("MUHAMMAD SHAKIR / MUHAMMAD YAKOOB (0002-000593) / JUNAGARH WALA")
dt.Rows.Add("MUHAMMAD SHAKIR / MUHAMMAD YAKOOB (0002-000594) / JUNAGARH WALA")
GridView1.DataSource = dt
GridView1.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 = Regex.Replace(e.Row.Cells(0).Text, "\([^()]*\)",
Function(ByVal match As Match) String.Format("(<a href='Details.aspx?Id={0}'>{0}</a>)",
match.Value.Replace("(", "").Replace(")", "")),
RegexOptions.IgnoreCase)
End If
End Sub
Screenshot