【问题标题】:how can i bind business object of c# in crystal or rdlc report?如何在水晶或 rdlc 报表中绑定 c# 的业务对象?
【发布时间】:2011-09-22 08:51:49
【问题描述】:

首先让我告诉你一件事,我还没有处理过任何类型的报告。我已阅读有关此主题的所有相关问题和答案。但找不到任何具体的解决方案。

我的问题是我有一个非常简单的报告,我必须从数据库的视图中显示一行。为了获得该行,我创建了一个业务对象(实体)。那个实体完美地支撑着我的行。我也尝试过水晶报告和rdlc报告。但最后我只会选择一个。所以我的解决方案中有一份水晶报告。在我的 aspx 表单中,我使用了一个报告查看器。但我不知道如何使这三件事协同工作,即报表、报表查看器和保存信息的对象或实体。

现在代码在这里

水晶报表的名称是 FormSaleMoneyReceipt.rpt

我的aspx页面是

<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
<div id = "SearchPlace">
    <label for ="">Candidate ID:</label><asp:TextBox runat = "server" ID = "txtCandidateId"></asp:TextBox>
    <label for ="">Form SL#:</label><asp:TextBox runat = "server" ID = "txtFormSl"></asp:TextBox>
    <asp:Button runat = "server" ID = "btnShowReport" Text = "Show Report" 
        onclick="btnShowReport_Click" />
</div>
<div id = "ReportViewrHolder">
    <CR:CrystalReportViewer ID="CrystalReportViewerMRN" runat="server" AutoDataBind="true" />
</div>
</form>

我的文件后面的代码是

protected void Page_Load(object sender, EventArgs e)
{
}

protected void btnShowReport_Click(object sender, EventArgs e)
{
    int candidateId = 0;

    string formSl = txtFormSl.Text;
    ViewFormSaleMoneyReceiptEntity formSaleMoneyReceiptEntity = new ViewFormSaleMoneyReceiptEntity();
    if(txtCandidateId.Text != "")
    {
        candidateId = Convert.ToInt32(candidateId);
        formSaleMoneyReceiptEntity = ViewFormSaleMoneyReceipt_DAO.GetMoneyReceiptByID(candidateId);
        //CrystalReportViewerMRN.ReportSource = formSaleMoneyReceiptEntity; 
    }
    if(txtFormSl.Text!="")
    {
        formSaleMoneyReceiptEntity = ViewFormSaleMoneyReceipt_DAO.GetMoneyReceiptByFormSL(formSl);
        //CrystalReportViewerMRN.ReportSource = formSaleMoneyReceiptEntity; 
    }
}

请给我一个解决方案,我迫切需要解决方案。提前感谢所有智能技术极客。

【问题讨论】:

    标签: c# asp.net crystal-reports rdlc


    【解决方案1】:

    您必须创建一个ReportSource 对象并将其分配给您的报告,如here 所述。

    CrystalReportViewerMRN.ReportSource = myReportSource;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-29
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多