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
Denis Morgan
NA
72
22.5k
Creating subreport in cystal report
Dec 14 2020 4:18 AM
I have created this model object in C# and want to create a report with sub report and don't know how to link the 2; Here is my model
public
class
LabReport
{
public
int
ref_id{
get
;
set
;}
public
String t_name {
get
;
set
; }
public
IList<LabSubReport> result {
get
;
set
; }
//this where i need subreport
}
public
class
LabSubReport
{
public
int
ref_id {
get
;
set
; }
//foreign key from Above model
public
String l_test {
get
;
set
; }
public
String t_value {
get
;
set
; }
}
and this is how Have populated my model
IList<LabReport> report=report=
new
List<LabReport>();
IList<LabRequestEntity> empo =
//dao to fetch data
int
count = 1;
foreach
(LabRequestEntity e
in
empo)
{
IList<LabTestNoteEntity> notes=e.test_note;
//entity relation ship here
IList<LabSubReport> sublist=
new
List<LabSubReport>();
foreach
(LabTestNoteEntity p
in
notes)
{
var sub=
new
LabSubReport()
{
l_test=p.test,
t_value=p.result
};
sublist.Add(sub);
}
var rpt =
new
LabReport()
{
ref_id =
""
+ count,
t_name=e.lab_test.t_name,
result=sublist
};
count++;
report.Add(rpt);
}
And I would wish my report to look this way. Where its highlighted with blue is where i need the sub-report to be
I have tried this
ReportDocument cryRpt =
new
ReportDocument();
cryRpt.Load(
"C:/MainReport.rpt"
);
cryRpt.DataSourceConnections.Clear();
cryRpt.SetDataSource(report);
cryRpt.Subreports[0].DataSourceConnections.Clear();
cryRpt.Subreports[0].SetDataSource(report.select(x=>x.result));
and getting this error
Column 'ref_id' does not belong to table LabSubReport
Reply
Answers (
1
)
Asp.net One design
Jquery Datatatable MVC not working After publish IIS