TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
2.1k
472.8k
crystal report not working using asp.net mvc in c#
Jul 21 2020 2:54 AM
Hi Team
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).
// Model
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
; }
}
// Controller
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"
);
}
Reply
Answers (
3
)
How to strone login user session id in database table?
RadScheduler calling OnClientAppointmentMoveEnd twice when i try to mo