Web应用程序项目 - ReportViewer控件 [英] Web Application Project - ReportViewer Control

查看:259
本文介绍了Web应用程序项目 - ReportViewer控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VS 2005 Web应用程序中使用ReportViewer控件

项目(不是网站项目)。

当我尝试创建新报告时(本地),我似乎找不到任何方法

来创建数据源。我想使用现有的类对象。

我发现的示例表明该类应该在App_Code

文件夹中。但是WAP没有App_Code文件夹。


有没有办法为WAP中的本地报告指定数据源,或者

必须所有报告是远程吗?


谢谢,


-


AG

电子邮件:讨论在adhdata dot com

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

推荐答案

您好AG,


根据您的描述,您''想知道如何在ASP.NET Web应用程序项目中为webform reportviewer控件提供数据源$

正确吗?


根据我的理解,对于webform reportviewer,您可以通过以下方式提供

数据源:


1)如果您使用.NET内置类型的DataSet / TableAdpater组件,你可以简单地添加一个新的类型DataSet(使用TableAdapter)和DataSet类

将出现在VS 2005 ide''中s网站数据源窗口。您可以将特定表格的属性(columsn)拖到客户报告(rdlc)的

设计界面上。


#Walkthrough:在ReportViewer Web服务器上使用数据库数据源

在本地处理模式下控制
http://msdn2.microsoft.com/en-us/lib...23(VS.80)。 aspx


#DataSet方法适用于网站项目和Web应用程序

项目。


2)或者如果你使用的是一些自定义类(返回DataTable或

typedDataTable),它似乎是内置的WebSite数据源。 windows可以

在设计时不显示它。解决方法的一种方法如下:


1.在报表查看器控件的SmartTag中,单击选择数据源。


2在Choose Data Sources对话框中,单击Data Source Instance

列并选择New Data Source。


3.在数据列表中选择Object来源。


4.在选择您的业务对象组合框中,您应该已经看到报表将使用的表适配器的

名称它拉了

数据......选择它。或者,如果您没有看到自定义类,请取消选中show

only data components;选项,以便列表中的所有业务类都可用




5.完成向导...你现在应该处于良好的状态。


或者您也可以手动选择在aspx模板中使用自定义类:

=============== =============

< rsweb:ReportViewer ID =" ReportViewer2" RUNAT = QUOT;服务器" >

< LocalReport ReportPath =" ClientReport1.rdlc">

< DataSources>

< rsweb:ReportDataSource

DataSourceId =" ObjectDataSource2"名称= QUOT; DataSet1_rpt_table" />

< / DataSources>

< / LocalReport>

< / rsweb:ReportViewer>

< asp:ObjectDataSource ID =" ObjectDataSource2" runat =" server"

SelectMethod =" GetDataTable"

TypeName =" WAPTestProj.MyDataSourceClass">< / asp:ObjectDataSource>

=============================


这里" WAPTestProj.MyDataSourceClass"是一个自定义类如下:


===========


公共类MyDataSourceClass

{

public DataSet1.rpt_tableDataTable GetDataTable()

{

DataSet1TableAdapters.rpt_tableTableAdapter ta = new

DataSet1TableAdapters.rpt_tableTableAdapter();


DataSet1.rpt_tableDataTable table = new

DataSet1.rpt_tableDataTable();


ta.Fill(表);


返回表;

}

}

== ================


此外,您还可以以编程方式创建和添加数据源

ReportViewer控件。这是一个网络论坛主题讨论这个问题:

http://forums.microsoft.com/MSDN/Sho...70944&SiteID=1



此致,


Steven Cheng


Microsoft MSDN在线支持主管


=========================================== =======


通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。


注意:MSDN托管新闻组支持服务是针对非紧急问题

如果社区或微软支持人员在1个工作日内做出初步回复是可以接受的。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx


==================================== ==============

此帖子按原样提供。没有保证,也没有授予任何权利。


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/lib...23(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/Sho...70944&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/subscripti...ult.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/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



感谢您的回复AG,


因此,您主要关注的是查看和使用自定义数据源对象

作者客户报告(RDLC)文件,对吗?


经过一些进一步的研究,我确实发现了一些关于

网站数据源的问题。窗口无法正确显示业务

对象类。并且还有一些社区成员在公共连接站点上提交了错误

请求(已被记录为内部

错误条目):

#114670。使用时,业务对象网站数据源消失

RDLC
https://connect.microsoft.com/Visual....aspx?Feedback

ID = 114670


到目前为止,我发现上述网址中的一个解决方法可以帮助我们在这个问题上获得一些帮助。正如一位成员所提到的,如果您的商务舱'

方法(返回将被绑定到报告数据的数据记录

区域)将返回一个列表(或Array)类型对象,可以识别并在WebSite数据源窗口中显示
。我已经在Web

应用程序项目中进行了测试,它确实有效。对于您的场景,您可以尝试添加一个

方法,该方法返回某个数据对象类的List或Array,并且

使用它来创建报告。您如何看待?


这是我使用的测试类,可以在网站数据源中显示

窗口。顺便说一下,我把它放在一个类库项目中:


===========

命名空间ClassLib

{

公共类MyDataSource

{


public List< EmployeeGetEmployees()

{

返回新列表<员工>();

}

}


[系统。 Diagnostics.DebuggerNonUserCodeAttribute()]

公共类员工

{

private int _id;

private string _name;


public int ID

{

get {return _id; }

set {_id = value; }

}


公共字符串名称

{

get {return _name; }

set {_name = value; }

}

}

}

============== =========


希望这会有所帮助。


此致,


Steven Cheng


Microsoft MSDN在线支持主管

此帖子按现状提供没有保证,也没有赋予任何权利。


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/Visual....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<EmployeeGetEmployees()
{
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.




谢谢史蒂文,


是的,我看到''List(of object)''被识别。

我的类已经返回数据表,但我还没有找到一个简单的方法

来转换数据表或数据视图到列表(对象)或列表(数组)。


有这样的方法吗?


-


AG

电子邮件:讨论adhdata dot com

" Steven Cheng [MSFT]" < st ***** @ online.microsoft.com写信息

新闻:Z9 ************** @ TK2MSFTNGHUB02.phx.gbl ...
Thanks Steven,

Yes, I see that ''List(of object)'' is recognized.
My classes already return datatables, but I have not found a simple method
to convert a datatable or dataview to a list(of object) or list(of array).

Is there such a method?

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Z9**************@TK2MSFTNGHUB02.phx.gbl...

感谢您的回复AG,


因此,您的主要关注点是在
作者客户报告(RDLC)文件,对吗?

经过一番深入研究后,我确实发现了一些关于

的问题网站数据源窗口无法正确显示业务

对象类。并且还有一些社区成员在公共连接站点上提交了错误

请求(已被记录为内部

错误条目):

#114670。使用时,业务对象网站数据源消失

RDLC
https://connect.microsoft.com/Visual....aspx?Feedback

ID = 114670


到目前为止,我发现上述网址中的一个解决方法可以帮助我们在这个问题上获得一些帮助。正如一位成员所提到的,如果您的商务舱'

方法(返回将被绑定到报告数据的数据记录

区域)将返回一个列表(或Array)类型对象,可以识别在WebSite数据源窗口中显示的


。我已经在Web

应用程序项目中进行了测试,它确实有效。对于您的场景,您可以尝试添加

a

方法返回某个数据对象类的List或数组,并且

将其用于作者那个报告。您如何看待?


这是我使用的测试类,可以在网站数据源中显示

窗口。顺便说一下,我把它放在一个类库项目中:


===========

命名空间ClassLib

{


公共类MyDataSource

{


public List< EmployeeGetEmployees()

{

返回新列表<员工>();

}

}


[System.Diagnostics.DebuggerNonUserCodeAttribute()]

公共类员工

{

private int _id;

private string _name;


public int ID

{

get {return _id; }

set {_id = value; }

}


公共字符串名称

{

get {return _name; }

set {_name = value; }

}

}

}

============== =========


希望这会有所帮助。


此致,


Steven Cheng


Microsoft MSDN在线支持主管


此帖子按原样提供。没有保证,也没有赋予

权利。


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/Visual....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<EmployeeGetEmployees()
{
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.




这篇关于Web应用程序项目 - ReportViewer控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆