protected void btnAddToCart_Click(object sender, EventArgs e) { if (Session["user"].ToString().Equals("Guest")) { Session["previous"] = "~/OneProduct.aspx"; Response.Redirect("~/login.aspx"); } else { Session["previous"] = "~/OneProduct.aspx"; string pimgurl = smaalimg; string pname = this.lblPname.Text; string uname = Session["user"].ToString(); string pprice = this.lblPprice.Text; double apprice = System.Convert.ToDouble(pprice); string quantity = DropDownList1.SelectedItem.ToString(); int aQuantity = System.Convert.ToInt32(quantity); bool status = dba.addProductToCart(uname, pimgurl, pname, apprice, aQuantity); if (status) { lbllError.Visible = true; lbllError.Text = pname + " add to the cart Successfully !"; } else { lbllError.Visible = true; lbllError.Text = pname + " already in the cart !"; } } }