Hi indradeo,
Check this sample. now take its reference.
HTML
<asp:GridView ID="gvFruits" runat="server">
</asp:GridView>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("pr_name");
dt.Columns.Add("Price");
dt.Rows.Add("1", "Apple", "100");
dt.Rows.Add("2", "Mango", "200");
dt.Rows.Add("3", "Banana", "300");
dt.Columns.Add("UniqueID");
foreach (DataRow row in dt.Rows)
{
row["UniqueID"] = row["pr_name"].ToString().Substring(0, 3) + row["Id"].ToString().PadLeft(3, '0');
}
this.gvFruits.DataSource = dt;
this.gvFruits.DataBind();
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim dt As DataTable = New DataTable()
dt.Columns.Add("Id")
dt.Columns.Add("pr_name")
dt.Columns.Add("Price")
dt.Rows.Add("1", "Apple", "100")
dt.Rows.Add("2", "Mango", "200")
dt.Rows.Add("3", "Banana", "300")
dt.Columns.Add("UniqueID")
For Each row As DataRow In dt.Rows
row("UniqueID") = row("pr_name").ToString().Substring(0, 3) + row("Id").ToString().PadLeft(3, "0"c)
Next
Me.gvFruits.DataSource = dt
Me.gvFruits.DataBind()
End Sub
Screenshot