簡體   English   中英

如何在Crystal或rdlc報表中綁定C#的業務對象?

[英]how can i bind business object of c# in crystal or rdlc report?

首先,讓我告訴您一件事,我還從未進行過任何形式的報告。 我已經閱讀了有關此主題的所有相關問答。 但是找不到任何具體的解決方案。

我的問題是我有一個非常簡單的報告,使我必須在數據庫視圖中顯示一行。 為了擁有該行,我創建了一個業務對象(實體)。 該實體完美地支持了我。 我也嘗試了水晶報表和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; 
    }
}

請,請給我一個解決方案,我非常需要該解決方案。 預先感謝所有智能技術怪才。

你必須創建一個ReportSource對象,並分配給您的報告,描述在這里

CrystalReportViewerMRN.ReportSource = myReportSource;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM