protected void ddl_sourceinfoid_SelectedIndexChanged(object sender, EventArgs e) { if (ddl_sourceinfoid.SelectedValue != string.Empty) { Int32.TryParse(ddl_sourceinfoid.SelectedValue, out Sourceinfoid); grid1.Visible = false; IEnumerable <AuditArchive> history = serv.GetAllArchiveByStatus(Sourceinfoid, false); ddl_history.Items.Clear(); ddl_history.Items.Add(new ListItem("Select a Historical Audit", "")); if (history.Count() > 0) { ddl_status.Enabled = true; ddl_status.SelectedIndex = 0; ddl_history.Enabled = true; ddl_history.SelectedIndex = 0; foreach (AuditArchive audit in history) { string status = audit.SourcePass == true ? "Passed" : audit.StartTime.AddDays(1) == audit.EndTime ? "Incomplete" : "Failed"; string option = " Date [ " + audit.StartTime.ToString() + " - " + audit.EndTime.ToString() + "], Status " + status; ddl_history.Items.Add(new ListItem(option, audit.SourceInfoId.ToString() + "|" + audit.Id.ToString())); } ViewState["history"] = history; } } else { ddl_status.Enabled = false; ddl_status.SelectedIndex = -1; ddl_history.Enabled = false; ddl_history.SelectedIndex = -1; } }