You are on page 1of 4

public void temp_save()

{
ViewState["TempTable"] = ViewState["DBCurrentTable"];
int rowIndex_temp = 0;
if (ViewState["TempTable"] != null)
{
//ViewState["TempTable"] = null;
DataTable dbdtCurrentTable_temp = (DataTable)ViewState["TempTable"];
DataRow drCurrentRow_temp = null;
if (dbdtCurrentTable_temp.Rows.Count > 0)
{
//ViewState["TempTable"] = null;
// dbdtCurrentTable_temp2 = null;
for (int i = 1; i <= dbdtCurrentTable_temp.Rows.Count; i++)
{
if (i <= dbdtCurrentTable_temp.Rows.Count)
{
//extract the TextBox values
TextBox box1 = (TextBox)grdDBDtl.Rows[rowIndex_temp].Cel
ls[1].FindControl("txtuid");
TextBox box2 = (TextBox)grdDBDtl.Rows[rowIndex_temp].Cel
ls[2].FindControl("txtpwd");
DropDownList grd = (DropDownList)grdDBDtl.Rows[rowIndex_
temp].Cells[3].FindControl("ddlusertype");
drCurrentRow_temp = dbdtCurrentTable_temp.NewRow();
drCurrentRow_temp["RowNumber"] = i + 1;
drCurrentRow_temp["vsuid"] = box1.Text;
drCurrentRow_temp["vspwd"] = box2.Text;
drCurrentRow_temp["vsname"] = grd.SelectedItem.Text;
drCurrentRow_temp["vssystype"] = grd.SelectedItem.Value;
}
rowIndex_temp++;
}

//add new row to DataTable


dbdtCurrentTable_temp.Rows.Add(drCurrentRow_temp);
//dbdtCurrentTable_temp2.Rows.Add(drCurrentRow_temp);

////Store the current data to ViewState


//ViewState["DBCurrentTable"] = dbdtCurrentTable_temp;
////Rebind the Grid with the current data
//grdDBDtl.DataSource = dbdtCurrentTable;
//grdDBDtl.DataBind();
}
}
else
{
Response.Write("ViewState is null");
}
}
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
========================================================
11:14 AM 9/24/20
10
================================================================================
=============================================================================
public void temp_save()
{
// ViewState["TempTable"] = ViewState["DBCurrentTable"];
int rowIndex_temp = 0;
if (ViewState["TempTable"] == null)
{
int row_count;

DataTable dbdtCurrentTable_temp = (DataTable)ViewState["DBCurrentTab


le"];
//if (loadtime == 0)
//{
// DataTable temp_temptable = (DataTable)ViewState["D
BCurrentTable"];
DataTable temp_11 = (DataTable)ViewState["DBCurrentTable"];
// loadtime = 1;

temp_temptable = temp_11.Clone();
//}
DataRow drCurrentRow_temp = null;
row_count = dbdtCurrentTable_temp.Rows.Count;
if (row_count > 0)
{

for (int i = 0; i < row_count; i++)


{
//extract the TextBox values
TextBox box1 = (TextBox)grdDBDtl.Rows[rowIndex_temp].Cel
ls[1].FindControl("txtuid");
TextBox box2 = (TextBox)grdDBDtl.Rows[rowIndex_temp].Cel
ls[2].FindControl("txtpwd");
DropDownList grd = (DropDownList)grdDBDtl.Rows[rowIndex_
temp].Cells[3].FindControl("ddlusertype");
//drCurrentRow_temp = dbdtCurrentTable_temp.NewRow();
drCurrentRow_temp = temp_temptable.NewRow();
drCurrentRow_temp["RowNumber"] = i + 1;
drCurrentRow_temp["vsuid"] = box1.Text;
drCurrentRow_temp["vspwd"] = box2.Text;
drCurrentRow_temp["vsname"] = grd.SelectedItem.Text;
drCurrentRow_temp["vssystype"] = grd.SelectedItem.Value;
//add new row to DataTable
temp_temptable.Rows.Add(drCurrentRow_temp);
rowIndex_temp++;
}

//dbdtCurrentTable_temp.Rows.Add(drCurrentRow_temp);
//dbdtCurrentTable_temp2.Rows.Add(drCurrentRow_temp);

////Store the current data to ViewState


//ViewState["DBCurrentTable"] = dbdtCurrentTable_temp;
////Rebind the Grid with the current data
//grdDBDtl.DataSource = dbdtCurrentTable;
//grdDBDtl.DataBind();
}
}
else
{
ViewState["TempTable"] = null ;
temp_save();
}

================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
================================================================================
=====================================================

You might also like