我有一個簡單的查詢表單,其中包括名字,姓氏等....首先我插入記錄,但當我點擊提交按鈕它說你必須首先登錄提交查詢。所以我登錄到網站,我需要的數據,我插入第一次在查詢形式的網站.....如何保持這一數據???。 ....所以我不需要再寫一遍。 這裏是我下面的代碼:在asp.net中保存數據
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
if (Session["userid"] != null)
{
if (FileUpload1.HasFile)
{
string str = FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath(".") + "//images//" + str);
string path = "~//images//" + str.ToString();
con.Open();
con.Close();
Label1.Text = "File uploaded successfully";
main addinfo = new main();
string Id = Request.QueryString["id"];
string SQL = "insert into mandir(user_id,name,place,description,with_religion_category,with_district,with_religion,photo)values('" + Session["userid"] + "','" + txttemplename.Text.Trim() + "','" + txtaddress.Text.Trim() + "','" + txtdescription.Value + "','" + ddlreligioncategory.SelectedItem.Value + "','" + ddlreligion.SelectedItem.Value + "','" + ddldistrict.SelectedItem.Value + "','" + path + "')";
addinfo.saveData(SQL);
txttemplename.Text = "";
txtaddress.Text = "";
txtdescription.Value = "";
lblenquirymsg.Text = "Thank you for providing the information";
}
else
{
Label1.Text = "File not uploaded successfully";
}
}
else
{
lblinfo.Text = "You Must Login Or Register To give information";
}
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
}
像userid存儲會話中的整個表單字段,並在這裏檢索它 – Rohan
你可以plz更具體 – user3132068