Quantcast
Channel: Visual Studio Report Controls Forum
Viewing all articles
Browse latest Browse all 519

a datasource instance has not supplied in wpf .net c#

$
0
0

I am getting error like "A Datasource instance has not been supplied in wpf .net c# in my app"

my code follows like

 public partial class PrintInvoice : Window
    {
        private System.Windows.Forms.BindingSource ProductBindingSource;
        private System.ComponentModel.IContainer mform_components = null;

        public PrintInvoice()
        {
            InitializeComponent();
            PrepareReport();
        }
        private void PrepareReport()
        {
            this.mform_components = new System.ComponentModel.Container();
            Microsoft.Reporting.WinForms.ReportDataSource reportDataSource = new Microsoft.Reporting.WinForms.ReportDataSource();
            this.ProductBindingSource = new System.Windows.Forms.BindingSource(this.mform_components);
            ((System.ComponentModel.ISupportInitialize)(this.ProductBindingSource)).BeginInit();

            
          

            reportDataSource.Name = "InvoiceWithStocksObjectCollection";
            reportDataSource.Value = this.ProductBindingSource;
              
            this._reportViewer.LocalReport.DataSources.Add(reportDataSource);
            //this._reportViewer.LocalReport.ReportEmbeddedResource = "project.Invoice.InvoicePrint.rdlc";
            this._reportViewer.LocalReport.ReportEmbeddedResource = "project.Invoice.InvoicePrint.rdlc";
            ((System.ComponentModel.ISupportInitialize)(this.ProductBindingSource)).EndInit();
        }
        public InvoiceWithStocksObjectCollection getData()
        {
            InvoiceWithStocksObjectCollection invoiceCollection = new InvoiceWithStockBLL().SelectAllInvoice();
            return invoiceCollection;
        }
      

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
             
                this.ProductBindingSource.DataSource = getData();
                this._reportViewer.RefreshReport();
              
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


Efforts may fail but don't fail to take effort -------------- sidd


Viewing all articles
Browse latest Browse all 519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>