private void SaveData() { data = new WebUserControlEnvironmentsData(); data.environmentsData.Add(TextBoxEnvironmentName.Text); data.environmentsData.Add(TextBoxEnvironmentCostEnter.Text); data.environmentsData.Add(TextBoxEnvironmentCostIn.Text); data.environmentsData.Add(TextBoxEnvironmentCostExit.Text); data.environmentsData.Add(TextBoxEnvironmentDamage.Text); data.environmentsData.Add(LabelEnvironmentNameError.Text); data.environmentsData.Add(LabelEnvironmentCostEnterError.Text); data.environmentsData.Add(LabelEnvironmentCostInError.Text); data.environmentsData.Add(LabelEnvironmentCostExitError.Text); data.environmentsData.Add(LabelEnvironmentDamageError.Text); }
protected void ButtonAddEnvironment_Click(object sender, EventArgs e) { WebUserControlEnvironments en = (WebUserControlEnvironments)LoadControl("~/WebUserControlEnvironments.ascx"); en.ID = PlaceHolderEnvironments.Controls.Count.ToString() + "_Environment"; PlaceHolderEnvironments.Controls.Add(en); List <WebUserControlEnvironmentsData> environData = EnvironmentsData; // Get it out of the viewstate WebUserControlEnvironmentsData enData = new WebUserControlEnvironmentsData(); enData = en.Data; environData.Add(enData); EnvironmentsData = environData; }
public void LoadData(WebUserControlEnvironmentsData other) { if (other.environmentsData.Count != 10) { throw new Exception("Opppsss"); } TextBoxEnvironmentName.Text = other.environmentsData[0]; TextBoxEnvironmentCostEnter.Text = other.environmentsData[1]; TextBoxEnvironmentCostIn.Text = other.environmentsData[2]; TextBoxEnvironmentCostExit.Text = other.environmentsData[3]; TextBoxEnvironmentDamage.Text = other.environmentsData[4]; LabelEnvironmentNameError.Text = other.environmentsData[5]; LabelEnvironmentCostEnterError.Text = other.environmentsData[6]; LabelEnvironmentCostInError.Text = other.environmentsData[7]; LabelEnvironmentCostExitError.Text = other.environmentsData[8]; LabelEnvironmentDamageError.Text = other.environmentsData[9]; SaveData(); }