This way:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Papercost" HeaderText="Paper Cost" />
<asp:BoundField DataField="PaperName" HeaderText="PaperName" />
</Columns>
</asp:GridView>
</div>
</form>
C#:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Session["Value"] = "5";
this.Bind();
}
}
private void Bind()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2]{
new DataColumn("Papercost", typeof(int)),
new DataColumn("PaperName", typeof(string)) });
dt.Rows.Add(2, "DNA");
dt.Rows.Add(3, "MUMBAI MIRROR");
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sebder, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = "$" + Session["Value"].ToString() + " " + DateTime.Now.ToString("hh:mm.ss");
}
}
Thank You.