protected void grdMenus_RowDeleting(object sender, GridViewDeleteEventArgs e) { FoodData.Menu menu = new FoodData.Menu(); menu.ID = Convert.ToInt32(((Label)grdMenus.Rows[e.RowIndex].FindControl("lblID")).Text); menu.Delete(); FillMenusGrid(); }
protected void grdMenus_RowUpdating(object sender, GridViewUpdateEventArgs e) { //DataTable menus = Session["dt"] as DataTable; FoodData.Menu menu = new FoodData.Menu(); menu.ID = Convert.ToInt32(((Label)grdMenus.Rows[e.RowIndex].FindControl("lblID")).Text); //menu.Name = ((TextBox)grdMenus.Rows[e.RowIndex].FindControl("txtName")).Text; menu.MealPeriodID = Convert.ToInt32(((DropDownList)grdMenus.Rows[e.RowIndex].FindControl("cmbMealPeriod")).SelectedValue); menu.ServiceDate = DateTime.ParseExact(((TextBox)grdMenus.Rows[e.RowIndex].FindControl("dtServiceDate")).Text, "dd.MM.yyyy HH:mm", provider); menu.Save(); grdMenus.EditIndex = -1; FillMenusGrid(); }
protected void grdMenus_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { FoodData.Menu menu = new FoodData.Menu(); menu.ID = -1; //menu.Name = ((TextBox)grdMenus.FooterRow.FindControl("txtNewName")).Text; menu.MealPeriodID = Convert.ToInt32(((DropDownList)grdMenus.FooterRow.FindControl("cmbNewMealPeriod")).SelectedValue); menu.ServiceDate = DateTime.ParseExact(((TextBox)grdMenus.FooterRow.FindControl("dtNewServiceDate")).Text, "dd.MM.yyyy HH:mm", provider); menu.Save(); FillMenusGrid(); } }