protected void ReportEditButton_Click(object sender, EventArgs e) { if (Page.IsValid) { ReportBLL bll = new ReportBLL(connectionString); ReportViewModel report = new ReportViewModel(); Dictionary <string, int> CarOwner_CarID = GetCarNameFromCarID(); report.ReportID = Convert.ToInt32(Request.QueryString["ReportID"]); int i; for (i = 0; i < CarOwner_CarID.Count; i++) { if (CarOwner_CarID.Keys.ToList()[i].Equals(CarIDList.SelectedItem.Text)) { break; } } report.CarID = CarOwner_CarID.Values.ToList()[i]; report.DateOfIncident = DateOfIncident.Text; report.ReportName = ReportName.Text; report.ReportDescription = ReportDescription.Text; report.DateOfReport = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); bll.EditIncidentReport(report); Response.Redirect("~/Reports.aspx"); } }