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";
}
在这里,会话变量Session["dfdtemptable"]
和Session["addedLOV"]
两者都更新了两次,并且每个会话变量的行数变为 2。但是每个会话变量的行数应该是 1。但是当另一个 Session 变量更新时,Session 变量也会更新。在分配或更新Session["dfdtemptable"]
时得到更新。Session["addedLOV"]
我无法弄清楚问题所在。