i am trying to pass a number of values from one page to another, i have managed to pass both the category ID and sub category ID, however i am unable to pass the "product_id" value. as you can see from below i am getting the product_id using a stored procedure.

what im aiming to do is when the user click the "LinkButton1 link" the use will be redirected to the item based on the product_ID, however i am unable to pass the product_id to the "LinkButton1_Click". anyone have any idea on the best way to approach this issue? can I pass the product_id to the "LinkButton1_Click"?.

thanks for any help.

protected void Page_Load(object sender, EventArgs e)
         {
          
            products_load();

         }

        private void products_load()
        {
            if (Request.QueryString["CategoryID"] != null && Request.QueryString["SubcatID"] != null)
            {

                int cat_id = (Convert.ToInt32(Request.QueryString["CategoryID"]));

                int sub_id = (Convert.ToInt32(Request.QueryString["SubcatID"]));


                using (api_prodDataContext api = new api_prodDataContext())
                {
                    var result_prod = from p in api.getProducts(sub_id)
                                      let i = api.getProductImg(p.product_img_id).SingleOrDefault()
                                      select new
                                      {
                                          p.product_name,
                                          p.product_price,
                                          p.product_sub_cat_id,
                                          p.product_id,
                                          p.product_desc,
                                          p.product_quantity,
                                          i.product_thumb_url,
                                          i.product_img_id
                                      };


                    ListView1.DataSource = result_prod.ToList();
                    ListView1.DataBind();


                }
            }
        }

 protected void listItems_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
        {
            this.DataPagerProducts.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
            products_load();
        }

public void LinkButton1_Click(object sender, EventArgs e)
        {
           
            int cat_id = (Convert.ToInt32(Request.QueryString["CategoryID"]));

            int sub_id = (Convert.ToInt32(Request.QueryString["SubcatID"]));

            int product_id = (Convert.ToInt32("PRODUCT ID TOGO HERE")); //issue here cannot get the valued from the stored procedure

           // Label1.Text = (Convert.ToString(ListView1.Items[4]));
           // int.TryParse(Request["product_id"], out product_id);

            

            Response.Redirect(string.Format("product_details.aspx?" + "CategoryID={0}" + "&SubcatID={1}" + "&product_id={2}", cat_id.ToString(), sub_id.ToString(), product_id.ToString()));

Recommended Answers

All 3 Replies

If all your values are present at form load, then you don't need to do this in code behind. just set the url on the link on your .aspx page to being ./product_details.aspx?CategoryID=<%= (Convert.ToInt32(Request.QueryString["CategoryID"])).ToString() %>&SubcatID=<%= (Convert.ToInt32(Request.QueryString["SubcatID"])).ToString() %>&product_id=<%= (Convert.ToInt32(Request.QueryString["PRODUCT ID TOGO HERE"])).ToString() %>

If all your values are present at form load, then you don't need to do this in code behind. just set the url on the link on your .aspx page to being ./product_details.aspx?CategoryID=<%= (Convert.ToInt32(Request.QueryString["CategoryID"])).ToString() %>&SubcatID=<%= (Convert.ToInt32(Request.QueryString["SubcatID"])).ToString() %>&product_id=<%= (Convert.ToInt32(Request.QueryString["PRODUCT ID TOGO HERE"])).ToString() %>

hey thanks worked like a charm, iv also learned something new, didn't realise it was possible to do that with the use of the EVAL.

thanks

You're welcome. There are lots of resources out there that can help to. "4 Guys from Rolla" is a really good resource for looking up how to do things.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.