Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need help on passing id to next page on response.redirect

Need help on passing id to next page on response.redirect

Scheduled Pinned Locked Moved ASP.NET
helpquestioncsharpdatabasesales
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bootzilla33
    wrote on last edited by
    #1

    I am inserting into the database and want to pass the id to the next page via response.redirect but am not sure how to do that. Here is the code I have:

    string custsrc = custsrccode.Text;
    string name = custname.Text;
    string city = custcity.Text;
    string state = custstate.Text;
    string postcode = custpostalcode.Text;
    string actcode = activitycode.SelectedItem.Text;
    string id = labelID.Text;
    string activityid = labelactivityid.Text;

    OracleConnection conn = new OracleConnection(); // C#
    conn.ConnectionString = strConnection;
    conn.Open();

                OracleCommand cmd = new OracleCommand();
                cmd.Connection = conn;
                cmd.CommandText = "INSERT INTO BUYING\_ACTIVITY (CUSTOMER\_SOURCE\_CODE, CUSTOMER\_NAME, CUSTOMER\_CITY, CUSTOMER\_STATE, CUSTOMER\_POSTAL\_CODE, BUYING\_ACTIVITY\_CODE, ID) " +
                "VALUES (:custsrc, :name, :city, :state, :postcode, :actcode, :id)";
    
    
                cmd.Parameters.Add(new OracleParameter("custsrc", custsrc));
                cmd.Parameters.Add(new OracleParameter("name", name));
                cmd.Parameters.Add(new OracleParameter("city", city));
                cmd.Parameters.Add(new OracleParameter("state", state));
                cmd.Parameters.Add(new OracleParameter("postcode", postcode));
                cmd.Parameters.Add(new OracleParameter("actcode", actcode));
                cmd.Parameters.Add(new OracleParameter("id", id));
    
                cmd.ExecuteNonQuery();
                
                conn.Close();
    

    Response.Redirect("contractinfo.aspx?Id=" + labelRID.Text);

    I get nothing on the labelID.Text when I step thru my code and then when it goes to the next page I obviously get nothing as well contractinfo.aspx?Id="" where the "" should be the id value. How do I fix this with the code I have.

    F 1 Reply Last reply
    0
    • B Bootzilla33

      I am inserting into the database and want to pass the id to the next page via response.redirect but am not sure how to do that. Here is the code I have:

      string custsrc = custsrccode.Text;
      string name = custname.Text;
      string city = custcity.Text;
      string state = custstate.Text;
      string postcode = custpostalcode.Text;
      string actcode = activitycode.SelectedItem.Text;
      string id = labelID.Text;
      string activityid = labelactivityid.Text;

      OracleConnection conn = new OracleConnection(); // C#
      conn.ConnectionString = strConnection;
      conn.Open();

                  OracleCommand cmd = new OracleCommand();
                  cmd.Connection = conn;
                  cmd.CommandText = "INSERT INTO BUYING\_ACTIVITY (CUSTOMER\_SOURCE\_CODE, CUSTOMER\_NAME, CUSTOMER\_CITY, CUSTOMER\_STATE, CUSTOMER\_POSTAL\_CODE, BUYING\_ACTIVITY\_CODE, ID) " +
                  "VALUES (:custsrc, :name, :city, :state, :postcode, :actcode, :id)";
      
      
                  cmd.Parameters.Add(new OracleParameter("custsrc", custsrc));
                  cmd.Parameters.Add(new OracleParameter("name", name));
                  cmd.Parameters.Add(new OracleParameter("city", city));
                  cmd.Parameters.Add(new OracleParameter("state", state));
                  cmd.Parameters.Add(new OracleParameter("postcode", postcode));
                  cmd.Parameters.Add(new OracleParameter("actcode", actcode));
                  cmd.Parameters.Add(new OracleParameter("id", id));
      
                  cmd.ExecuteNonQuery();
                  
                  conn.Close();
      

      Response.Redirect("contractinfo.aspx?Id=" + labelRID.Text);

      I get nothing on the labelID.Text when I step thru my code and then when it goes to the next page I obviously get nothing as well contractinfo.aspx?Id="" where the "" should be the id value. How do I fix this with the code I have.

      F Offline
      F Offline
      F ES Sitecore
      wrote on last edited by
      #2

      You read the id from labelID

      string id = labelID.Text;

      But the ID you are passing on the query string is labelRID

      Response.Redirect("contractinfo.aspx?Id=" + labelRID.Text);

      If it's the same id use the same label, or just re-use the id variable

      Response.Redirect("contractinfo.aspx?Id=" + id);

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups