Hi I'm trying to pass data from one page to another, but it does not display anything,
Page 1:
protected void submit_Click(object sender, EventArgs e)
{
addData();
Session["value"] = space_01.Text;
}
public void addData()
{
string tenderDate = start_txt.Text;
string cost = totalCost.Text;
string companyName = name_txt.Text;
string scon =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|calculator2.mdb";
string str =
"INSERT INTO form_input(companyName, tenderDate, cost) VALUES(companyName, tenderDate, cost)";
string id = "Select @@Identity";
int f_id;
using (OleDbConnection con = new OleDbConnection(scon))
{
using (OleDbCommand cmd = new OleDbCommand(str, con))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("companyName", companyName);
cmd.Parameters.AddWithValue("tenderDate", tenderDate);
cmd.Parameters.AddWithValue("cost", cost);
con.Open();
cmd.ExecuteNonQuery();
cmd.CommandText = id;
f_id = (int)cmd.ExecuteScalar();
Response.Redirect("output.aspx?f_id=" + f_id);
}
}
}
Page 2:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["value"] != null)
space.Text = Session["value"].ToString();
}
}