我有一个简单的查询表单,其中包括名字,姓氏等....首先我插入记录,但当我点击提交按钮它说你必须首先登录提交查询。所以我登录到网站,我需要的数据,我插入第一次在查询形式的网站.....如何保持这一数据???。 ....所以我不需要再写一遍。 这里是我下面的代码:在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