You are not restoring the data table that you saved in session.
Try this
private DataTable CreatEmptyDT()
{
DataTable dt = new DataTable();
dt.Columns.Add(new System.Data.DataColumn("Name", typeof(String)));
dt.Columns.Add(new System.Data.DataColumn("Address", typeof(String)));
dt.Columns.Add(new System.Data.DataColumn("Cell", typeof(String)));
return dt;
}
public DataTable CurrentData
{
get
{
object o = Session["CurrentData"];
if (o == null)
return CreatEmptyDT();
else
return (DataTable)o;
}
set { Session["CurrentData"] = value; }
}
protected void btnsave_Click(object sender, EventArgs e)
{
DataTable dt = CurrentData;
DataRow dr = dt.NewRow();
dr[0] = TextBox1.Text;
dr[1] = TextBox2.Text;
dr[2] = TextBox3.Text;
dt.Rows.Add(dr);
CurrentData = dt;
clearfields();
}
Cheers