【问题标题】:SSRS Raport dosn't show in ReportViewer using EntityFramwork DataSource使用实体框架数据源的 SSRS 报告未显示在 ReportViewer 中
【发布时间】:2020-06-23 04:28:06
【问题描述】:

我想在 ReportViewer 控件中使用 SSRS rdlc 制作报告页面

这里是我的 ReportViewer 代码

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="510px" Width="978px">
        </rsweb:ReportViewer>

    </div>
    </form>
</body>

然后这里是我的控制代码

Imports Microsoft.Reporting.WebForms

Public Class ReporingForm
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ReportViewer1.ProcessingMode = ProcessingMode.Local
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("Reporting.rdlc")
        Dim entities As DepenseEntities = New DepenseEntities
        Dim datasource As ReportDataSource = New ReportDataSource("Dossiers", (From dossier In entities.Dossier.Take(10) Select dossier))
        ReportViewer1.LocalReport.DataSources.Clear()
        ReportViewer1.LocalReport.DataSources.Add(datasource)
    End Sub

End Class

我没有收到任何执行错误,但我的 ReportViewer 不断刷新无限循环

这是我的结果网页

请注意,我在我的项目中使用 MVC 应用程序,并为 reportViewer 使用 WebForm

任何人都可以解决这个问题吗? 如何使用 DataSet 将 EF 数据源转换为数据源

【问题讨论】:

    标签: asp.net-mvc entity-framework reporting-services webforms reportviewer


    【解决方案1】:

    这应该可行:

                Dim report = New LocalReport()
    report.SetBasePermissionsForSandboxAppDomain(New PermissionSet(PermissionState.Unrestricted))
    ReportViewer1.ProcessingMode = ProcessingMode.Local
    ReportViewer1.LocalReport.ReportPath = Server.MapPath("Reporting.rdlc")
    Dim result = //get data from your entities into a list for example.
    datasource = New ReportDataSource("DataSet1", result)
    ReportViewer1.LocalReport.DataSources.Clear()
    ReportViewer1.LocalReport.DataSources.Add(datasource)
    ReportViewer1.LocalReport.Refresh()    
    

    因此,只需将您的数据从您的实体过滤到一个列表左右,它应该可以工作。我希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-09
      相关资源
      最近更新 更多