Question

I'm taking StimulSoft Report for .net as my third-party report to create my BusinessObject reports.

Here is my Customer Class

class CustomerSet
    {
        public string CustomerID { get; set; }
        public string CompanyName { get; set; }
        public string ContactName { get; set; }
        public string ContactTitle { get; set; }
    }

LINQ to SQL is my DataAccess Component

Load all customer IDs to a listbox

 private void CustomerReport_Load(object sender, EventArgs e)
        {
            var idQuery = from c in db.Customers
                         select c.CustomerID;

            listBox1.DataSource = idQuery;
        }

When user select an ID from the listbox and click on Show button, it will query a Customer info based on the that ID and generate a report.

     private void btnShow_Click(object sender, EventArgs e)
            {
                try
                {
                    var custQuery = from c in db.Customers
                                      where c.CustomerID == listBox1.SelectedValue.ToString()
                                      select new CustomerSet { 
                                       CustomerID=c.CustomerID,
                                       CompanyName=c.CompanyName,
                                       ContactName=c.ContactName,
                                       ContactTitle=c.ContactTitle
                                      };
                    customersBindingSource.Clear();
                    customersBindingSource.Insert(0,custQury.FirstOrDefault());

                    stiReport1.RegReportDataSources();
                    stiReport1.Show();
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }

It's OK for the first time, but when user close the report and select new ID and show the report, the report displays the old record.

Please note that the report is created by the Report Wizard and uses customersBindingSource as it's DataSource which drag and drop from the DataSource windows.

Did I miss something? Can anyone help?

Thanks...

Was it helpful?

Solution

Please try to use the RegData() method instead RegReportDataSources(). Also please try to use the Render() method before show report.

OTHER TIPS

Add this before RegReportDataSources:

stiReport1.BusinessObjectsStore.Clear();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top