The given below is the example.Go through this.
In .ASPX page:
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="false" xmlns:asp="#unknown">
<columns>
<asp:templatefield headertext="L1">
<itemtemplate><asp:label id="lbl1" runat="server" text="<%# Bind("L1") %>"></asp:label></itemtemplate>
</asp:templatefield>
<asp:templatefield headertext="L1">
<itemtemplate><asp:label id="lbl2" runat="server" text="<%# Bind("L2") %>"></asp:label></itemtemplate>
</asp:templatefield>
<asp:templatefield headertext="L1">
<itemtemplate><asp:linkbutton id="lbl3" runat="server" text="<%# Bind("L3") %>"></asp:linkbutton></itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>
In .CS page:
protected void Page_Load(object sender, EventArgs e)
{
DataTable table1 = new DataTable("DTBLE1");
table1.Columns.Add("L1");
table1.Columns.Add("L2");
table1.Columns.Add("L3");
table1.Rows.Add("1", 5);
table1.Rows.Add("3", 5);
table1.Rows.Add("4", 9);
table1.Rows.Add("7", 3);
table1.Rows.Add("6", 6);
DataSet Dset = new DataSet("DSET1");
Dset.Tables.Add(table1);
if (Dset.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < Dset.Tables[0].Rows.Count; i++)
{
DataRow dr = Dset.Tables[0].Rows[i];
int a = Convert.ToInt32(dr["L1"]);
int b = Convert.ToInt32(dr["L2"]);
int c = a * b;
dr["L3"] = c.ToString();
}
}
GridView1.DataSource = Dset;
GridView1.DataBind();
}
Best of luck.