public ActionResult Consumption(string Year, string Month, string productCategory, string DeliveryZoneCode, string cdc, string IP, string SCTO, string sdate, string edate, string fc) { ReportsModel obj = new ReportsModel(); if (Year == "") { Year = null; } if (Month == "") { Month = null; } if (productCategory == "") { productCategory = null; } if (DeliveryZoneCode == "") { DeliveryZoneCode = null; } if (cdc == "") { cdc = null; } if (IP == "") { IP = null; } if (SCTO == "") { SCTO = null; } if (fc == "") { fc = null; } obj.Year = Year; obj.Month = Month; obj.productCategory = productCategory; obj.DeliveryZoneCode = DeliveryZoneCode; obj.cdc = cdc; obj.IP = IP; obj.SCTO = SCTO; obj.fc = fc; DateTime?StartDate; //= DateTime.ParseExact(sdate, "dd/MM/yyyy", null); DateTime?EndDate; //= DateTime.ParseExact(edate, "dd/MM/yyyy", null); if ((!sdate.Contains("null") && sdate != "") || (!edate.Contains("null") && edate != "")) { StartDate = DateTime.ParseExact(sdate, "dd/MM/yyyy", null); EndDate = DateTime.ParseExact(edate, "dd/MM/yyyy", null); } else { StartDate = null; // Convert.ToDateTime(DBNull.Value); EndDate = null; // Convert.ToDateTime(DBNull.Value); } obj.StartDate = StartDate; obj.EndDate = EndDate; Microsoft.Reporting.WebForms.ReportViewer reportViewer = new Microsoft.Reporting.WebForms.ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\LMIS_Reports\Consumption.rdlc"; reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("amc", obj.GetConsumption().ToList())); ViewBag.ReportViewer = reportViewer; return(View()); }