rdgerken
Technical User
- Jul 8, 2002
- 108
Hi all.
Can someone please help me set up a data source to a report on an asp.net application dynamically at runtime? I have everything working when I just set it up using the editor, but now I would like to programatically set the datasource at run time. Here's what I have so far, but no luck.
Where the name of my XSD file is A2IO, and the table name is IO.
as you can see, I'm having trouble getting the data from my table adapter into the report. How does one make this connection? I have an objectdatasource on the page, and it's just pulling the data through that. I don't really want to change that, but I do want to change the select method that the objectdatasource is using at run time.
I'm sure this is hard to understand, so maybe someone out there can just show me how to take a table adapter, an objectdatasource, and a reportviewer control and do some magic!
Thanks,
Ryan
Can someone please help me set up a data source to a report on an asp.net application dynamically at runtime? I have everything working when I just set it up using the editor, but now I would like to programatically set the datasource at run time. Here's what I have so far, but no luck.
Where the name of my XSD file is A2IO, and the table name is IO.
Code:
A2IOTableAdapters.IOTableAdapter io1 = new A2IOTableAdapters.IOTableAdapter();
int? areaid = this.ddArea.SelectedIndex;
io1.GetDataByAreaID(areaid);
ReportViewer1.LocalReport.ReportPath = @"c:\inetpub\[URL unfurl="true"]wwwroot\development\reports\cmindex.rdlc";[/URL]
ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("A2IO_IO"));
ReportViewer1.LocalReport.Refresh();
as you can see, I'm having trouble getting the data from my table adapter into the report. How does one make this connection? I have an objectdatasource on the page, and it's just pulling the data through that. I don't really want to change that, but I do want to change the select method that the objectdatasource is using at run time.
I'm sure this is hard to understand, so maybe someone out there can just show me how to take a table adapter, an objectdatasource, and a reportviewer control and do some magic!
Thanks,
Ryan