private void BindInitialData() { ShiftDataEntryFound_HiddenField.Value = "false"; WardName_DropDownList.DataSource = DataRepository.Instance.AllWards; WardName_DropDownList.DataTextField = "WardName"; WardName_DropDownList.DataValueField = "WardCode"; WardName_DropDownList.DataBind(); Shift_DropDownList.DataSource = DataRepository.Instance.AllShiftTypes; Shift_DropDownList.DataTextField = "Name"; Shift_DropDownList.DataValueField = "ShiftID"; Shift_DropDownList.DataBind(); UnSafeMitigation_DropDownList.DataSource = DataRepository.Instance.UnSafeMitigations; UnSafeMitigation_DropDownList.DataBind(); // Inserting the default text to the dropdowns if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["DropDownDefaultText"])) { ListItem defaultItem = new ListItem(ConfigurationManager.AppSettings["DropDownDefaultText"]); UnSafeMitigation_DropDownList.Items.Insert(0, defaultItem); } }
private void BindInitialData() { StaffingDateRangeDA staffingDateRangeDA = new StaffingDateRangeDA(); List <StaffingDateRange> staffingDates = staffingDateRangeDA.GetAllStaffingDateRanges(); currentWards = DataRepository.Instance.AllWards; WardName_DropDownList.DataSource = currentWards; WardName_DropDownList.DataTextField = "WardName"; WardName_DropDownList.DataValueField = "WardCode"; WardName_DropDownList.DataBind(); //Modify the date range text foreach (StaffingDateRange staffingDate in staffingDates) { string startDate = staffingDate.StartDate.ToShortDateString(); string endDate = staffingDate.EndDate.ToShortDateString(); if (endDate == "01/01/0001") { endDate = Constants.EndDateNotSpecified; } staffingDate.DisplayPeriod = string.Format("{0} to {1}", startDate, endDate); } DatePeriodRange_DropDownList.DataSource = staffingDates; DatePeriodRange_DropDownList.DataTextField = "DisplayPeriod"; DatePeriodRange_DropDownList.DataValueField = "Index"; DatePeriodRange_DropDownList.DataBind(); Shift_DropDownList.DataSource = DataRepository.Instance.AllShiftTypes; Shift_DropDownList.DataTextField = "Name"; Shift_DropDownList.DataValueField = "ShiftID"; Shift_DropDownList.DataBind(); }
private void BindShifts(IList <StaffingData> staffingData) { List <string> shifts = staffingData.Select(data => data.Shift).Distinct().ToList(); if (null != shifts) { Shift_DropDownList.DataSource = shifts; Shift_DropDownList.DataBind(); } }