public ActionResult ClassAttendance() { string classname = ReportsController.classname; int classid = 1; DB37Entities db = new DB37Entities(); if (classname == "All") { ViewBag.warn = "Invalid Student Registration Number"; return(RedirectToAction("AdminReportsOnly")); } classid = db.Classtbls.Where(t => t.Section == classname).FirstOrDefault().Id; //CrMVCApp.Models.Customer c; var c = db.AttendanceofWholeClass(classid).ToList(); ClassAttendanceReport rpt = new ClassAttendanceReport(); rpt.Load(); rpt.SetDataSource(c); Stream s = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(s, "application/pdf")); }