private void btnInHDGTGT_Click(object sender, RoutedEventArgs e)
{
//this is create ReportBook
ReportBook book = new ReportBook();
//create ReportViewer add to control Wpf of WinReport.xaml
WinReport WinReport = new WinReport();
//foreach in grvOrder get order (master) => orderDetails
foreach (Order order in grvOrder.Items)
{
//Create list orderDetails
List<OrderDetail> listOrderDetails = new List<OrderDetail>();
foreach (OrderDetail OrderDetail in order.OrderDetails)
{
//add all orderdetails to listOrderDetails
listOrderDetails.Add(OrderDetail);
}
//this is a template of report RptOrderGTGTDemo.cs ==> container information orderDetails show report
RptOrderGTGTDemo RptOrderGTGT = new RptOrderGTGTDemo();
//add source to report item
RptOrderGTGT.Report.DataSource = listOrderDetails;
//add multiple report item to reportbook
book.Reports.Add(RptOrderGTGT);
}
//out of foreach add report to ReportViewer
WinReport.rptReport.Report = book;
WinReport.ShowDialog();
}
----------------------
an error : System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.ReportViewer.Wpf.ReportViewerModel.Print()
at Telerik.ReportViewer.Wpf.ReportViewerModel.PrintReportCommandImpl.Execute(Object parameter)
at Telerik.ReportViewer.Wpf.ReportViewerModel.Command.System.Windows.Input.ICommand.Execute(Object parameter)
thanks!
{
//this is create ReportBook
ReportBook book = new ReportBook();
//create ReportViewer add to control Wpf of WinReport.xaml
WinReport WinReport = new WinReport();
//foreach in grvOrder get order (master) => orderDetails
foreach (Order order in grvOrder.Items)
{
//Create list orderDetails
List<OrderDetail> listOrderDetails = new List<OrderDetail>();
foreach (OrderDetail OrderDetail in order.OrderDetails)
{
//add all orderdetails to listOrderDetails
listOrderDetails.Add(OrderDetail);
}
//this is a template of report RptOrderGTGTDemo.cs ==> container information orderDetails show report
RptOrderGTGTDemo RptOrderGTGT = new RptOrderGTGTDemo();
//add source to report item
RptOrderGTGT.Report.DataSource = listOrderDetails;
//add multiple report item to reportbook
book.Reports.Add(RptOrderGTGT);
}
//out of foreach add report to ReportViewer
WinReport.rptReport.Report = book;
WinReport.ShowDialog();
}
----------------------
an error : System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.ReportViewer.Wpf.ReportViewerModel.Print()
at Telerik.ReportViewer.Wpf.ReportViewerModel.PrintReportCommandImpl.Execute(Object parameter)
at Telerik.ReportViewer.Wpf.ReportViewerModel.Command.System.Windows.Input.ICommand.Execute(Object parameter)
thanks!