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