protected void Page_Load(object sender, EventArgs e) { Session["npath"] = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"]; Session["npath"] += "/" + HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"]; Session["npath"] += "?" + HttpContext.Current.Request.ServerVariables["QUERY_STRING"]; if (!IsPostBack) { if (Session["NewCartPacket"] != null) { NewCartPacket nPacket = (NewCartPacket)Session["NewCartPacket"]; string errorString; if (Session["UserID"] != null) { ShoppingCart.AddToCart(Session["UserID"].ToString(), nPacket, out errorString); Session["NewCartPacket"] = null; } else { Response.Redirect("Login.aspx"); } } //bindGrid(); } }
protected void grdListProperty_RowCommand(object sender, GridViewCommandEventArgs e) { DataTable dt = customUtility.GetTableData("select * from " + customUtility.DBPrefix + "Catalog where id=" + e.CommandArgument).Tables[0]; if (dt.Rows.Count > 0) { NewCartPacket nPacket = new NewCartPacket(); nPacket.ProductID = dt.Rows[0]["ID"].ToString(); nPacket.ProductName = dt.Rows[0]["CatalogName"].ToString(); nPacket.Productquantity = dt.Rows[0]["Quantity"].ToString(); TextBox txt = (TextBox)grdListProperty.Rows[Convert.ToInt32(e.CommandName)].Cells[3].Controls[1]; nPacket.Quantity = Convert.ToInt32(txt.Text); nPacket.ActualPrice = Convert.ToSingle(dt.Rows[0]["Price"].ToString()); nPacket.TotalPrice = (Convert.ToSingle(dt.Rows[0]["Price"].ToString())); Session["NewCartPacket"] = nPacket; string errorString; if (Session["UserID"] != null) { if (ShoppingCart.AddToCart(Session["UserId"].ToString(), nPacket, out errorString)) { Response.Redirect("~/Mycart.aspx"); } //Response.Redirect("~/Mycart.aspx?Catalog=" + dt.Rows[0]["CatalogName"].ToString()); else { lblErrorMessage.Visible = true; lblErrorMessage.Text = errorString.ToString(); } } else { Session["RedirPath"] = "~/Mycart.aspx?Catalog=" + dt.Rows[0]["CatalogName"].ToString(); Response.Redirect("Login.aspx"); } } }