Exemple #1
0
 protected void gdMenuItems_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("Insert"))
     {
         int menuId = Session["menuId"] == null ? -1 : Convert.ToInt32(Session["menuId"]);
         FoodData.MenuItem menu_item = new FoodData.MenuItem();
         menu_item.ID           = -1;
         menu_item.MenuID       = menuId;
         menu_item.IngredientID = Convert.ToInt32(((DropDownList)gdMenuItems.FooterRow.FindControl("cmbNewIngredient")).SelectedValue);
         menu_item.Weight       = Convert.ToDecimal(((TextBox)gdMenuItems.FooterRow.FindControl("txtNewWeight")).Text);
         menu_item.Save();
         FillMenuItemsGrid(menuId);
     }
 }
Exemple #2
0
        protected void gdMenuItems_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            //DataTable menus = Session["dt"] as DataTable;
            int menuId = Session["menuId"] == null ? -1 : Convert.ToInt32(Session["menuId"]);

            FoodData.MenuItem menu_item = new FoodData.MenuItem();
            menu_item.ID           = Convert.ToInt32(((Label)gdMenuItems.Rows[e.RowIndex].FindControl("lblID")).Text);
            menu_item.MenuID       = menuId;
            menu_item.IngredientID = Convert.ToInt32(((DropDownList)gdMenuItems.FooterRow.FindControl("cmbIngredient")).SelectedValue);
            menu_item.Weight       = Convert.ToDecimal(((TextBox)gdMenuItems.FooterRow.FindControl("txtWeight")).Text);
            menu_item.Save();
            gdMenuItems.EditIndex = -1;
            FillMenuItemsGrid(menuId);
        }