|
|
|
start date: Sun, 19 Aug 2007 20:57:40 -0400,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
AG am
|
|
2
(Steven Cheng[MSFT])
|
|
3
AG am
|
|
4
(Steven Cheng[MSFT])
|
Web Application Project - ReportViewer Control
I am trying to use a ReportViewer control in a VS 2005 web application
project (not Website project).
When I try to create a new report (local), I can't seem to find any method
to create a datasource. I would like to use an existing class object.
The examples I have found state that the class should be in the App_Code
folder. However a WAP does not have an App_Code folder.
Is there any way to specify a datasource for a local report in a WAP, or
must all reports be remote?
Thanks,
--
AG
Email: discuss at adhdata dot com
Date:Sun, 19 Aug 2007 20:57:40 -0400
Author:
|
RE: Web Application Project - ReportViewer Control
Hi AG,
From your description, you're wondering how to supply the DataSource for
the webform reportviewer control in an ASP.NET Web Application Project,
correct?
Based on my understanding, for webform reportviewer, you can supply the
datasource through the following means:
1) if you use the .NET built-in typed DataSet/TableAdpater components, you
can simply add a new typed DataSet(with TableAdapter) and the DataSet class
will appear in the VS 2005 ide's "Website Datasource" window. You can drag
the certain table's properties(columsn) onto the client report(rdlc)'s
design surface.
#Walkthrough: Using a Database Data Source with the ReportViewer Web Server
Control in Local Processing Mode
http://msdn2.microsoft.com/en-us/library/ms252123(VS.80).aspx
#the DataSet approach will work in both website project and Web Application
Project.
2) Or if you're using some custom class(which return the DataTable or
typedDataTable ), it seems the built-in "WebSite Data Source" windows can
not display it at design-time. One way to workaround it is as below:
1. In the SmartTag for the Report Viewer control, click Choose Data Source.
2. In the Choose Data Sources dialog, click inside the Data Source Instance
column and choose New Data Source.
3. Choose Object in the list of data sources.
4. In the Choose your business object combo-box, you should already see the
name of the Table Adapter that your report will use when it pulls
data...choose it. Or if you do not see your custom class, uncheck the "show
only data components" option so that all businesss classes will be availale
in the list:
5. Finish off the wizard...you now should be in good shape.
Or you can also manually select to use a custom class in aspx template:
============================
<rsweb:ReportViewer ID="ReportViewer2" runat="server" >
<LocalReport ReportPath="ClientReport1.rdlc">
<DataSources>
<rsweb:ReportDataSource
DataSourceId="ObjectDataSource2" Name="DataSet1_rpt_table" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="GetDataTable"
TypeName="WAPTestProj.MyDataSourceClass"></asp:ObjectDataSource>
=============================
Here the "WAPTestProj.MyDataSourceClass" is a custom class as below:
===========
public class MyDataSourceClass
{
public DataSet1.rpt_tableDataTable GetDataTable()
{
DataSet1TableAdapters.rpt_tableTableAdapter ta = new
DataSet1TableAdapters.rpt_tableTableAdapter();
DataSet1.rpt_tableDataTable table = new
DataSet1.rpt_tableDataTable() ;
ta.Fill(table);
return table;
}
}
==================
In addition, you can also programmatically create and add datasource for
ReportViewer control. Here is a web forum thread discuss on this:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1770944&SiteID=1
Hope this helps some.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 20 Aug 2007 09:01:42 GMT
Author:
|
Re: Web Application Project - ReportViewer Control
Thanks Steven,
My project already contains business object classes that return datatables,
for accessing all data, so it would be good to be able to utilize them and
not have to create new datasets for every report.
Therefore, I am trying to go with your option 2.
The smart tag choose datasources does not work the way you indicate. The
option is not available until a report has been created and then there is no
option for 'new data source', or for 'show only data components'.
Therefore, I followed your aspx example.
The thing here is that the report does not recognize the datasource, so it
can't be designed.
How can I get the report to recognize the datasource in order to design it?
--
AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" wrote in message
news:OH8YFjw4HHA.6140@TK2MSFTNGHUB02.phx.gbl...
> Hi AG,
>
> From your description, you're wondering how to supply the DataSource for
> the webform reportviewer control in an ASP.NET Web Application Project,
> correct?
>
> Based on my understanding, for webform reportviewer, you can supply the
> datasource through the following means:
>
> 1) if you use the .NET built-in typed DataSet/TableAdpater components, you
> can simply add a new typed DataSet(with TableAdapter) and the DataSet
> class
> will appear in the VS 2005 ide's "Website Datasource" window. You can drag
> the certain table's properties(columsn) onto the client report(rdlc)'s
> design surface.
>
> #Walkthrough: Using a Database Data Source with the ReportViewer Web
> Server
> Control in Local Processing Mode
> http://msdn2.microsoft.com/en-us/library/ms252123(VS.80).aspx
>
> #the DataSet approach will work in both website project and Web
> Application
> Project.
>
>
>
> 2) Or if you're using some custom class(which return the DataTable or
> typedDataTable ), it seems the built-in "WebSite Data Source" windows can
> not display it at design-time. One way to workaround it is as below:
>
> 1. In the SmartTag for the Report Viewer control, click Choose Data
> Source.
>
> 2. In the Choose Data Sources dialog, click inside the Data Source
> Instance
> column and choose New Data Source.
>
> 3. Choose Object in the list of data sources.
>
> 4. In the Choose your business object combo-box, you should already see
> the
> name of the Table Adapter that your report will use when it pulls
> data...choose it. Or if you do not see your custom class, uncheck the
> "show
> only data components" option so that all businesss classes will be
> availale
> in the list:
>
> 5. Finish off the wizard...you now should be in good shape.
>
>
>
> Or you can also manually select to use a custom class in aspx template:
>
>
> ============================
> <rsweb:ReportViewer ID="ReportViewer2" runat="server" >
> <LocalReport ReportPath="ClientReport1.rdlc">
> <DataSources>
> <rsweb:ReportDataSource
> DataSourceId="ObjectDataSource2" Name="DataSet1_rpt_table" />
> </DataSources>
> </LocalReport>
> </rsweb:ReportViewer>
> <asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
> SelectMethod="GetDataTable"
>
> TypeName="WAPTestProj.MyDataSourceClass"></asp:ObjectDataSource>
> =============================
>
> Here the "WAPTestProj.MyDataSourceClass" is a custom class as below:
>
> ===========
>
> public class MyDataSourceClass
> {
> public DataSet1.rpt_tableDataTable GetDataTable()
> {
> DataSet1TableAdapters.rpt_tableTableAdapter ta = new
> DataSet1TableAdapters.rpt_tableTableAdapter();
>
> DataSet1.rpt_tableDataTable table = new
> DataSet1.rpt_tableDataTable() ;
>
> ta.Fill(table);
>
> return table;
> }
> }
> ==================
>
> In addition, you can also programmatically create and add datasource for
> ReportViewer control. Here is a web forum thread discuss on this:
>
> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1770944&SiteID=1
>
> Hope this helps some.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>
> ==================================================
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>
>
Date:Mon, 20 Aug 2007 10:40:17 -0400
Author:
|
Re: Web Application Project - ReportViewer Control
Thanks for your reply AG,
So your main concern is to view and use the custom datasource objects when
author the client report(RDLC) file, correct?
After some further research, I did found some existing problem about the
"Website Data Sources" windows which can not correctly display Business
object classes. And there is also some community members submit bug
requests on the public connect site(which has been recorded as an internal
bug entry):
#114670. Business Object Website Data Sources vanish when working with
RDLC
https://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?Feedback
ID=114670
So far I found that one of the workaround in the above url can helps us
some on this issue. As one member mentioned, if your business class's
method(which return the data records that will be bound to report data
region) will return an List(or Array) type object, it can be recognized and
displayed in the WebSite datasource window. I've tested in a Web
Application Project and it does work. For your scenario, you can try add a
method that return an List or Array of the certain data object class and
use it to author the report. How do you think?
Here is a test class I used which can be display in "website data sources"
window. BTW, I put it in a class library project:
===========
namespace ClassLib
{
public class MyDataSource
{
public List<Employee> GetEmployees()
{
return new List<Employee>();
}
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public class Employee
{
private int _id;
private string _name;
public int ID
{
get { return _id; }
set { _id = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
}
}
=======================
Hope this helps some.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 23 Aug 2007 07:04:09 GMT
Author:
|
|
|