This is a migrated thread and some comments may be shown as answers.

TableAdapter Filtering please help.

1 Answer 164 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 09 May 2007, 12:31 PM
Hi

I have added a table adatpter and dataset as my datasources for the report,

I have built a query in  the table adapter that will get values according to query parameters.

I have made both the table adpater and dataset public, so is it possible for me to use

report.tableAdapter1.fillBy(dataset1.table, "Param1","Param2");

and query the information like that ?

Please help

1 Answer, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 09 May 2007, 05:09 PM
Hi Stuart Calder,

Your scenario looks realistic and I don't see any reason not to work. It seems that you want to fill the data set from outside the report. If this is correct I would suggest another approach that you can try: create the data adapter, commands, connection, and data set, fill it from outside the report and then pass the prepared data set/table to the report. The Report.DataSource property is public so you actually don't have to add any new fields and properties to the report class. Moreover you can handle the Report.NeedDataSource event from the outside of the report and prepare the data set there.

Here is a sample code that demonstrates the above:

class Class1
{
    Report report1;
   
    public Class1()
    {
        this.report1 = new Report1();
        this.report1.NeedDataSource += new EventHandler(this.report1_NeedDataSource);
    }
 
    ...
   
    void report1_NeedDataSource(object sender, System.EventArgs e)
    {
        string param1 = "Param1";
        string param2 = "Param2";
       
        report1.DataSource = this.CreateDataSource(param1, param2);
    }
   
    DataSet CreateDataSet(string param1, string param2)
    {
        DataSet ds = new DataSet();
        DbDataAdapter adapter = null;
        ...
        adapter.Fill(ds);
        ..
        return ds;
    }   
}



Let us know if you have further questions.


Sincerely yours,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Stuart
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Share this question
or