int rowIndex = 0; if (ViewState["CurrentTable1"] != null) { DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable1"]; DataTable DtLast = null; DataRow drCurrentRow = null; if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { //extract the TextBox values TextBox box1 = (TextBox)Gridview1.Rows[rowIndex]. Cells[1].FindControl("TxtName"); TextBox box2 = (TextBox)Gridview1.Rows[rowIndex]. Cells[2].FindControl("TxtStatus"); TextBox box3 = (TextBox)Gridview1.Rows[rowIndex]. Cells[3].FindControl("TxtAddress"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["SrNo"] = i + 1; drCurrentRow["Name"] = box1.Text; drCurrentRow["Status"] = box2.Text; drCurrentRow["Address"] = box3.Text; rowIndex++; DtLast.Rows.Add(drCurrentRow); } //add new row to DataTable //Store the current data to ViewState ViewState["CurrentTable1"] = dtCurrentTable; //Rebind the Grid with the current data Gridview1.DataSource = dtCurrentTable; Gridview1.DataBind(); } }
//Store the current data to ViewState ViewState["CurrentTable1"] = DtLast; //Rebind the Grid with the current data Gridview1.DataSource = DtLast; Gridview1.DataBind();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)