Link to home
Start Free TrialLog in
Avatar of dwezil
dwezilFlag for United Kingdom of Great Britain and Northern Ireland

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
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();
 
      
    }
 
  }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gyanendra Singh
Gyanendra Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dwezil

ASKER

Cheers
Avatar of dwezil

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"]);

Open in new window