protected void ddlBrojObroka_SelectedIndexChanged(object sender, EventArgs e) { lblError.Text = string.Empty; if (ddlBrojObroka.SelectedIndex != 0) { lblStartDate.Visible = true; txtStartDate.Visible = true; lblEndDate.Visible = true; txtEndDate.Visible = true; btnSpremi.Visible = true; btnOdustani.Visible = true; btnOnemoguci.Visible = false; if (mealRatioList == null) { mealRatioList = new List <MealRatio>(); } int selectedNumberOfMeals = int.Parse(ddlBrojObroka.SelectedValue); isActive = SQLProcedures.CheckForSavedCombination(selectedNumberOfMeals); if (isActive) { btnSpremi.Visible = false; btnOdustani.Visible = false; btnOnemoguci.Visible = true; mealCombination = SQLProcedures.GetSavedCombination(selectedNumberOfMeals); mealRatioList = SQLProcedures.GetMealRatios(mealCombination.IDCombination); txtStartDate.Text = mealCombination.StartDate.ToString(DATE_FORMAT); if (mealCombination.EndDate != DateTime.MinValue) { txtEndDate.Text = mealCombination.EndDate.ToString(DATE_FORMAT); } gvCombinations.DataSource = mealRatioList; gvCombinations.DataBind(); } else { txtStartDate.Text = string.Empty; txtEndDate.Text = string.Empty; for (int i = 0; i < selectedNumberOfMeals; i++) { MealRatio mr = new MealRatio { Meal = new Meal { IDMeal = 0, Name = string.Empty }, FatPortion = 0, CarbPortion = 0, ProteinPortion = 0, TotalPortion = 0 }; mealRatioList.Add(mr); } gvCombinations.DataSource = mealRatioList; gvCombinations.DataBind(); } } else { lblStartDate.Visible = false; txtStartDate.Visible = false; lblEndDate.Visible = false; txtEndDate.Visible = false; btnSpremi.Visible = false; btnOdustani.Visible = false; btnOnemoguci.Visible = false; gvCombinations.DataSource = null; gvCombinations.DataBind(); } FillObrociDDL(); }