public ActionResult StudentTermWiseMarks() { string classname = ReportsController.classname; if (classname == "All") { return(RedirectToAction("AdminReportsOnly", "Reports")); } int studentid = 1; int termid = 0; DB37Entities db = new DB37Entities(); studentid = db.Studentstbls.Where(t => t.RegistrationNumber == ReportsController.studentreg).FirstOrDefault().Id; termid = db.Termstbls.Where(t => t.Name == ReportsController.termname).FirstOrDefault().Id; //CrMVCApp.Models.Customer c; var c = db.TermWiseMarksOfEachStudent(studentid, termid).ToList(); TermWiseMarks rpt = new TermWiseMarks(); rpt.Load(); rpt.SetDataSource(c); Stream s = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(s, "application/pdf")); }