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
Sai Yang
NA
136
27.4k
[C# + sql server 2012] how to implement with two subreport?
May 25 2018 5:34 AM
Hi again!
I using C# + SQL SERVER 2012 and crystalreport. I have a dataset1 that contains 2 datatables (tb_car and tb_tool).
I design a report contains subreport (cardetail) and subreport (toolwith) for both datatables. And I have two datagridview(dgvcar and dgvtool)
I need to send the value from two datagridviews to two datatables and display on the two subreport
But I don’t know how to write the code
There are place to writing the code like button_click event and frm_preview load event. I place my code like that.
Code on button_click event like:
DataTable tbcar =
new
DataTable();
tbcar.Columns.Add(
"CarID"
);
tbcar.Columns.Add(
"Type"
);
tbcar.Columns.Add(
"Branch"
);
tbcar.Columns.Add(
"Year"
);
tbcar.Columns.Add(
"Color"
);
foreach
(DataGridViewRow drgs
in
dgvcar.Rows)
{
tbcar.Rows.Add(drgs.Cells[0].Value, drgs.Cells[1].Value, drgs.Cells[2].Value, drgs.Cells[3].Value, drgs.Cells[4].Value);
}
DataTable tbtool =
new
DataTable();
tbtool.Columns.Add(
"TID"
);
tbtool.Columns.Add(
"CarID"
);
tbtool.Columns.Add(
"Tname"
);
tbtool.Columns.Add(
"QTY"
);
tbtool.Columns.Add(
"Date"
);
foreach
(DataGridViewRow drg
in
dgvtool.Rows)
{
tbtool.Rows.Add(drg.Cells[0].Value, drg.Cells[1].Value, drg.Cells[2].Value, drg.Cells[3].Value, drg.Cells[4].Value);
}
Frm_preview fpv =
new
Frm_preview();
fpv.tbgetcar = tbcar;
fpv.tbgettool =tbtool;
fpv.ShowDialog();
and how to give the code on form_load event in frm_preview.
I can get only one dgv value to display on report
my code in form load like:
public
DataTable tbgetcar =
new
DataTable();
public
DataTable tbgettool=
new
DataTable();
private
void
crystalReportViewer1_Load(
object
sender, EventArgs e)
{
re1.Load(
"Rptcardetail.rpt"
, OpenReportMethod.OpenReportByDefault);
re1.SetDataSource(tbgetcar);
crystalReportViewer1.ReportSource = re1;
}
This code I give like normally report. It not give me any result in what I need.
Could you give me any right implement in this method.
Much appreciate,
Thank you.
Reply
Answers (
1
)
How to get pdf file from outside root folder
How to shorting in DataTable if value 1 to 10 and above