dwezil
asked on
How pass data from one page to another? - ASP.NET C #
Hello, I have the following statement to pull out email addresses from my db depending on selections made from a ddl list (I have added txttest to test that email is being retrieved). I would normally have a response.redirect after the conn close to open my confirmation.aspx page. This page display a "request number". I want to be able to access the email along with the req number. from the confrimation.aspx page when it is opened so I can then send out an email. How can I pass the data from this page to my cofirm page??
method = post??, PostBackUrl="Confirmation. aspx? Help is much appreciated, thanks
method = post??, PostBackUrl="Confirmation.
string EmailAddress;
string commandString1 = "SELECT Email FROM tblNewCategory WHERE Category like '" + ddlCategory.SelectedValue + "'";
SqlCommand myCommand1 = new SqlCommand(commandString1, myConnection);
SqlDataReader myReader = myCommand1.ExecuteReader();
myReader.Read();
if (myReader.HasRows)
{
EmailAddress = myReader.GetString(0);
txttest.Text = EmailAddress;
}
else
{
txttest.Text = "nowt";
// No data was returned from the execution of the myCommand.ExecuteReader();
}
myConnection.Close();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Figured it out. Thanks though guys both ways work! Cheers
//Current Page cs//
if (IsPostBack)
{
Session["sEmail"] = txtEmail.Text;
Response.Redirect("Confirmation.aspx");
}
//Confirmation Page Cs//
txtEmail1.Text = Convert.ToString(Session["sEmail"]);
ASKER