开发者

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

开发者 https://www.devze.com 2023-04-06 20:37 出处:网络
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.

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, i.e. 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 = "Report开发者_如何学CViewrHolder">
    <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.


You have to create a ReportSource object and assign that to your report, as described here.

CrystalReportViewerMRN.ReportSource = myReportSource;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号