I need some help, i am uble to get my crystal-report well and need guidance. I have try to use this logic and got nullable exception (SetDatasource).
-
- public class TrainingRegForm
- {
- [Key]
- public Guid? Id { get; set; }
- public string Title { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Position { get; set; }
- public string Company { get; set; }
-
- public string StreetAddress { get; set; }
-
- public string StreetAddressLine { get; set; }
-
- public string City { get; set; }
- public string StateProvince { get; set; }
-
- public int ZipCode { get; set; }
-
- public string Email { get; set; }
-
- [Required(ErrorMessage = "This field is required")]
- [DataType(DataType.PhoneNumber)]
- public string CellNumber { get; set; }
- public string DietaryRequirement { get; set; }
- }
-
-
- public ActionResult Download_XMLReport()
- {
- eNtsaRegistration context = new eNtsaRegistration();
-
- ReportDocument rpt = new ReportDocument();
- rpt.Load(Path.Combine(Server.MapPath("~/Reports"), "AcademyReports.rpt"));
- rpt.SetDataSource(from TrainingRegForm in context.TrainingRegs.Take(5) select TrainingRegForm); // This throws an error each time i debug it and its annoying and need som help here.
-
- Response.Buffer = false;
- Response.ClearContent();
- Response.ClearHeaders();
-
- rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
- rpt.PrintOptions.ApplyPageMargins(new CrystalDecisions.Shared.PageMargins(5, 5, 5, 5));
- rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA5;
-
- Stream stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
- stream.Seek(0, SeekOrigin.Begin);
-
-
-
-
- return File(stream, "application/xml", "eNtsaReportTrainingForm.xml");
- }