public ActionResult ClassWiseStudentTotalMarks() { string classanme = ReportsController.classname; DB37Entities db = new DB37Entities(); if (classname == "All") { var c2 = db.TotalMarksOfAllClasses().ToList(); TotalMarksOfClass rpt2 = new TotalMarksOfClass(); rpt2.Load(); rpt2.SetDataSource(c2); Stream s2 = rpt2.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(s2, "application/pdf")); } int classid = 1; classid = db.Classtbls.Where(t => t.Section == classname).FirstOrDefault().Id; //CrMVCApp.Models.Customer c; var c = db.TotalMarksOfEachClass(classid).ToList(); TotalMarksOfClass rpt = new TotalMarksOfClass(); rpt.Load(); rpt.SetDataSource(c); Stream s = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(s, "application/pdf")); }