Vik*_*kas 6 asp.net-mvc reportviewer reporting-services
如何集成ReportViewer
asp.net MVC项目?
我想添加MVCProject.Model
命名空间的业务对象.ReportViewer
允许DataSet的Business对象.
是否可以选择其他数据源,如LinqDataSource
LINQ-to-SQL类对象的Direct对象?
在MVC项目中添加报告的最佳解决方案是什么?
这会很艰难。首先,您需要 ViewState,因此您需要将报表托管在常规 WebForms 页面中。不过这还不算太糟糕 - WebForms 和 MVC 可以很好地并行工作。
困难的部分是绑定到真正的 IEnumerable 对象,而不是那些虚假的 ObjectDataSource。
第一步是建立报告数据模型。您可以通过代码、查询等方式完成此操作。像这样的结构(但显然要大得多)是典型的:
public class ReportSource
{
public Floogle[] Floogles { get; set; }
}
public class Floogle
{
public Doodad[] Doodads { get; set; }
public string Text { get; set; }
}
public class Doodad
{
public int Number { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
诀窍是在报表中使用 BindingSource 控件并将 DataSource 属性设置为typeof(ReportSource)
- 是的,数据源是报表模型的类型。
设计报告时,您不会获得太多的丰富内容,但您将能够做到。
就第三方报告解决方案而言,我们发现 Telerik 是最佳选择。
归档时间: |
|
查看次数: |
10746 次 |
最近记录: |