title: How do I use the value in the link?
body: <p>I am not sure how to ask this question and I have tried to look for the solution but no luck since I don't know what to search for... So I had a linkbutton to direct the user to the addtocart.aspx with the id of the product and the link should look like this</p>
  
  <pre class="lang-none prettyprint-override"><code>addtocart.aspx/?id=1
  </code></pre>
  
  <p>My problem is how do I use the id value that is in the link I redirect the user to and save it to another database for cart. This is what I current progress and still cant get the id to show up (This code is under Page Load of addtocart.aspx)</p>
  
  <pre class="lang-cs prettyprint-override"><code>if (!IsPostBack)
  {
      String contact_id = Id;
      int intTest = Convert.ToInt32(contact_id);
  
      string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
  
      using (SqlConnection con = new SqlConnection(constr))
      {
          using (SqlCommand cmd = new SqlCommand("SELECT * FROM Product WHERE Id=" + intTest))
          {
              using (SqlDataAdapter sda = new SqlDataAdapter())
              {
                  cmd.Connection = con;
                  sda.SelectCommand = cmd;
                  using (DataTable dt = new DataTable())
                  {
                      sda.Fill(dt);
  
                      foreach (DataRow row in dt.Rows)
                      {
                          string id = row["Id"].ToString();
                          string Product_Name = row["Product_Name"].ToString();
                          string Product_Price = row["Product_Price"].ToString();
                          string username = Session["Username"].ToString();
  
                          con.Close();
                          con.Open();
                          string query = "INSERT INTO Cart (Guest_Id, Product_Name, Product_Price) values (@Guest_Id, @Product_Name, @Product_Price)";
  
                          SqlCommand cmd1 = new SqlCommand(query, con);
  
                          cmd1.Parameters.AddWithValue("@Username", username);
                          cmd1.Parameters.AddWithValue("@Product_Name", Product_Name);
                          cmd1.Parameters.AddWithValue("@Product_Price", Product_Price);
  
                          cmd1.ExecuteNonQuery();
  
                          Response.Redirect("Dining.aspx");
  
                          con.Close();
                      }
                  }
              }
          }
      }
  }
  </code></pre>