我搜索了很多..但未能實現。 這裏是我的代碼,我如何防止重複插入頁面刷新,,(我如何使用viewstate,或任何其他方法.... resposnse.redirect不是在這種情況下的解決方案)。防止頁面刷新時出現重複記錄插入
protected void btn_save_click(object sender, EventArgs e)
{
System.Data.DataTable dt_plotid = new System.Data.DataTable();
dt_plotid = FghBAL.Admitting.GetMax_ByPlotID(txt_plot.Text);
string plotid = dt_plotid.Rows[0]["ID"].ToString();
if (FghBAL.Alotee.InserAllotee(txt_alotee_name.Text.ToUpper(), ddl_alotee_sw.SelectedValue.ToUpper(), txt_alotee_fname.Text.ToUpper(), alotee_cnic, txt_alotee_phone.Text, txt_alotee_cellno.Text, txt_alotee_address.Text, txt_alotee_email.Text, plotid))
{
lbl_error_3.Visible = true;
lbl_error_3.Text = "Add Successfully";
txt_alotee_name.Enabled = false;
ddl_alotee_sw.Enabled = false;
txt_alotee_fname.Enabled = false;
txt_alotee_cnic_1.Enabled = false;
txt_alotee_cnic_2.Enabled = false;
txt_alotee_cnic_3.Enabled = false;
txt_alotee_phone.Enabled = false;
txt_alotee_cellno.Enabled = false;
txt_alotee_address.Enabled = false;
txt_alotee_email.Enabled = false;
System.Data.DataTable dt_alotee_data = new System.Data.DataTable();
dt_alotee_data = FghBAL.Alotee.GetDatabyPlot_Id(plotid);
grid_alotee.DataSource = dt_alotee_data;
grid_alotee.DataBind();
grid_alotee.Visible = true;
btn_save_alotee.Visible = true;
btn_link_another_alotee.Visible = true;
lbl_grd_alotee.Visible = true;
tabcontent3.Style.Add("height", "80%");
//ViewState["dt_alotee_view"] = dt_alotee_data;
btn_save_alotee.Enabled = false;
// Response.Redirect(Request.Url.AbsoluteUri);
}
else
{
lbl_error_3.Text = "Unable to add Allottee Information";
}
}
* resposnse.redirect在這種情況下不是解決方案*爲什麼? – 2014-10-26 14:38:16
,因爲它移動到第一個標籤..但我希望它留在當前標籤..即時通訊在同一頁上使用多個標籤(標籤由單選按鈕控制) – 2014-10-26 14:40:35
在InserAllotee方法中添加一個重複的檢查邏輯。 – 2014-10-26 14:42:18