简体   繁体   中英

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

First let me tell you one thing, I have never worked with any sort of reporting yet. I have read all the related question and answer on this topic. But could not find any concrete solution.

My problem is I have a very simple report to make where I have to show a row from a view from the database. In order to have that row, I have created a business object (entity). that entity is holding my row perfectly. I have tried crystal report and rdlc report as well. But at the end I will choose only one. So I have a crystal report in my solution. In my aspx form I have taken a report-viewer. but I don know how to make these three things work together, ie the report, the report viewer and the object or entity that is holding the information.

Now the code goes here

the name of the crystal report is FormSaleMoneyReceipt.rpt

my aspx page is

<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>

My code behind file is

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; 
    }
}

please, please give me a solution, I am desperately in need of the solution. Thank you all the smart tech geeks in advance.

你必须创建一个ReportSource对象,并分配给您的报告,描述在这里

CrystalReportViewerMRN.ReportSource = myReportSource;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM