Session variable gets updated automatically
- by user1869914
protected void btningAccept_Click(object sender, EventArgs e)
{
if(!(txtLOVCode.Text==" "||txtLOVvalue.Text==" "))
{
rowid++;
// DFDLOVlst.Visible=true;
DataTable dt = createTemptable();
dt = (DataTable)Session["dfdtemptable"];
DataRow dr = dt.NewRow();
dr["prociLOV_Id"] = rowid;
dr["prociLOV_Value"] = txtLOVvalue.Text;
dr["prociLOV_Code"] = txtLOVCode.Text;
Boolean isalreadyinLOVlst = false;
foreach (DataRow chkrow in dt.Rows)
{
if (String.Equals(dr["prociLOV_Value"].ToString().Trim(), chkrow["prociLOV_Value"].ToString().Trim(),StringComparison.CurrentCultureIgnoreCase)
&& String.Equals(dr["prociLOV_Code"].ToString().Trim(), chkrow["prociLOV_Code"].ToString().Trim(), StringComparison.CurrentCultureIgnoreCase))
{
isalreadyinLOVlst = true;
break;
}
}
if (isalreadyinLOVlst)
{
this.lblMessage.Text = "LOV value: " + dr["prociLOV_Value"].ToString() + ": " + dr["prociLOV_Code"].ToString() + " already exits";
}
else
{
this.lblMessage.Text = " ";
dt.Rows.Add(dr);
DataTable addedLOV = createTemptable();
addedLOV = (DataTable)Session["addedLOV"];
addedLOV.ImportRow(dr); ;
Session["addedLOV"] = addedLOV;
}
DFDLOVlst.DataSource = dt;
DFDLOVlst.DataBind();
// dt.AcceptChanges();
Session["dfdtemptable"] = dt;
txtLOVCode.Text = "";
txtLOVvalue.Text = "";
MDIngrdientsCode.Hide();
this.txtLOVvalue.ReadOnly = false;
this.txtLOVCode.ReadOnly = false;
}
else
this.lblMessage.Text="NO LOV VALUES ENTERED";
}
Here the session varible Session["dfdtemptable"] and Session["addedLOV"] both gets updated twice and their row count becomes 2 for each session varible..But the row count sholud be 1 for each session varible.But the Session variable gets updated on the other Session varibles updation..
The Session["dfdtemptable"] gets updated when Session["addedLOV"] is assigned or updated..Can't figure out the problem..?