protected void GridViewIngredients_RowCommand(object sender, GridViewCommandEventArgs e) { int tempIngredientID = Convert.ToInt32(e.CommandArgument); int mycount = IngredientList.Count(); //Response.Redirect(IngredientList.Count().ToString()); if (e.CommandName == "Delete") { if (IngredientSession != null) { IngredientList = IngredientSession; //context.DeleteFromIngredient(tempIngredientID); IngredientList.RemoveAt(tempIngredientID); IngredientSession = IngredientList; } } GridViewIngredients.DataSource = IngredientList; GridViewIngredients.DataBind(); if (IngredientList.Count() == 0) { IngredientSession.Clear(); //Response.Redirect("http://localhost:28901/Default.aspx"); } }
protected void GetIngredientInfo() { int tempid = Convert.ToInt32(Session["RecipeID"]); GridViewIngredients.DataSource = context.GetRecipeIngredient(tempid); GridViewIngredients.DataBind(); }
protected void AddButton_Click(object sender, EventArgs e) { bool ingredientExist = false; if (!ingredientExist) { IngredientClass myingredient = new IngredientClass(TextBoxIngredient.Text, Convert.ToInt32(TextBoxQuantity.Text), TextBoxUnit.Text); if (IngredientSession != null) { IngredientList = IngredientSession; } IngredientList.Add(myingredient); //Response.Redirect(IngredientList.Last().ToString()); //IngredientList = IngredientSession; GridViewIngredients.DataSource = IngredientList; GridViewIngredients.DataBind(); IngredientSession = IngredientList; //Response.Redirect(IngredientList.Count().ToString()); TextBoxIngredient.Text = ""; TextBoxQuantity.Text = ""; TextBoxUnit.Text = ""; //allIngredients(); } else { Response.Redirect("HTIEJWOK"); } }