Based on your requirement, The solution is to use TemplateField. You may refer the links in my previous Post to understand the details of how this works. To address the specific case you pointed out, I made a sample. I created a gridview as below.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:BoundField DataField="Id" HeaderText="Sr"/>
<asp:BoundField DataField="Name" HeaderText="Name"/>
<asp:TemplateField HeaderText="Name - Customized" >
<ItemTemplate>
<%# AddLink(Eval("Name").ToString()) %>
</ItemTemplate>Fie
</asp:TemplateField>
</Columns>
</asp:GridView>
See, in the template column, I am calling a method and passing the value of "Name" column as a parameter. Let me show you the code from code behind.
The following is the Page_Load method.
protected void Page_Load(object sender, EventArgs e)
{
ds = new DataSet();
DataTable table = new DataTable();
table.TableName = "MyTable";
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(2, "Mrs. ABC");
table.Rows.Add(3, "Mrs. DEF");
table.Rows.Add(3, "Ms. GHI");
table.Rows.Add(3, "Miss JKL");
ds.Tables.Add(table);
GridView1.DataSource = ds;
GridView1.DataBind();
}
// Basically I am just defining a Dataset with the the sample data you provided and binding it to the Gridview. You may do it by binding gridview to your datasource. Now for the Addlink method, which I initiated from the TemplateField, see the code below.
protected string AddLink(string name)
{
if(name == "Mrs. DEF")
{
return $"<a href='https://www.asp.net'>{name}</a>";
}
else
{
return name;
}
}
You may replace the Addlink method with any complex logic you have, you can also pass multiple parameters from templatefield to the codebehind method...
Hope this helps.