Call the different report "tables" or "datasets" from within the rdlc, swap
the displayed report tables with parameters passed into the reportviewer.

        private void ButtonTableA_Clicked(object sender, EventArgs e)
        {
              SetSelectedTable("TableA", sender, e);
         }
        private void ButtonTableB_Clicked(object sender, EventArgs e)
        {
              SetSelectedTable("TableB", sender, e);
        }

        private void SetSelectedTable(string TableName, object sender,
EventArgs e)
        {
            ReportParameter p = new
                      ReportParameter("SelectedTable", TableName);
            this.reportViewer1.LocalReport.SetParameters(new
ReportParameter[] { p });
            this.reportViewer1.RefreshReport();
        }

On Thu, Nov 19, 2009 at 7:12 PM, Mr. B <[email protected]> wrote:

> Hello
>
> I want to write a simple application. Simple as in it is easy to
> describe but i can't figure it out.
>
> This application that i want to create has a report viewer that shows
> the contents of the tables in the database as reports. I have a
> database with two tables in it: TableA and TableB. The GUI of the
> application has two button plus the reportviewer. One of the buttons
> is called A and the other one B. When i click the button A i want the
> report viewer to display the contents of TableA. When i click the
> button B i want ... you guessed it... the reportviewer to display the
> contents of TableB as a report.
>
> The problem i have is that i cannot seem to assign a new data source
> to the reportviewer. When you add a reportviewer to your app in visual
> studio 2008 you have to give it a datasource. I do this but then i
> can't change this data source later in the application. I have created
> separate rdlc files for the two reports and i am trying to give the
> reportviewer a new data source but it seems to be "stuck" with the
> data source that it got when i created it. I have googled this a lot
> and all i can see is that i need a DataSet that contains the info from
> the tables and i have to use this dataset as a datasource but it's not
> working. Does anybody have some sample code that does this? Or knows
> where i can find it? I have looked but could not find it. A thourough
> explanation would also be nice. Thanks in advance.
>
> Cheers
>



-- 
Wendi
cell: 949-606-4877

"Energizer Bunny arrested, charged with battery."

Reply via email to