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 回更新され、セッション変数ごとに行数が 2 になります。ただし、各セッション変数の行数は 1 である必要があります。ただし、セッション変数は、他のセッション変数が更新されると更新されます。が割り当てられるか更新Session["dfdtemptable"]
されると、が更新されます。Session["addedLOV"]
問題がわかりません。