Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,
i want to display data in my crystalereportviewer, i have create crystaleReport after i have chose an empty report => expert base de données and i create new connexion and i chose my table wich i want to display data , whene i clic Overview report pricipale i can see my data but whene i bind my CrystalReportViewer there' no data
this's my code

C#
protected void Page_Load(object sender, EventArgs e)
    {
       ReportDocument reportdocument = new ReportDocument();
       reportdocument.Load(Server.MapPath("~/CrystalReport1.rpt"));
       crpview.ReportSource = reportdocument;
    }


<CR:CrystalReportViewer ID="crpview" runat="server" AutoDataBind="true" />
Posted
Comments
Sajith Dilhan 21-Jul-15 7:25am    
call databind explicitly and check

crpview.Databind();
Member 11573837 21-Jul-15 7:30am    
hi Sajith Dilhan,
thank you for answering me i have add crpview.Databind(); and no change

1 solution

ASP.NET
Please refer the Below example :- 
<cr:crystalreportviewer id="SAPcrystalReport"  runat="server" autodatabind="true" hascrystallogo="False" width="100%" xmlns:cr="#unknown" />


C#
private void Page_Init(object sender, EventArgs e)
        {
                ReportDocument rd;
                EmployeeReport ds = new EmployeeReport(); //Dataset Name
                DataTable dt = ds.Tables["empTable"];
                DataRow row;
                List<asiemployeedal> lstEmployee = asiEmployeeDAL.SelectAllEmployee();

                foreach (var objlst in lstEmployee.Take(100))
                {
                    row = dt.NewRow();
                    row["empID"] = objlst.empID.ToString();
                    row["empName"] = objlst.empName;
                    row["address"] = objlst.address;
                    row["city"] = objlst.city;
                    row["contactNo"] = objlst.contactNo.ToString();
                    dt.Rows.Add(row);
                }

                rd = new AllEmployeeReport(); //RPT File Name
                rd.SetDataSource(dt);

                SAPcrystalReport.ReportSource = rd;
                SAPcrystalReport.DataBind();
        }
 
Share this answer
 
v3
Comments
Member 11573837 21-Jul-15 9:23am    
hi Anil Vaghasiya,
thank you for answering me but me i didn't use dataset i'm using "OLE DB (ADO) new connexion" how can i solve it because i have seen exemple and i do like them and don't work for me
Anil Vaghasiya 21-Jul-15 9:34am    
Hello,

No need to Connect (OLEDB(ADO)) for add DataSet e.g EmployeeReport.xsd.

Firstofall Right Click on Project and Click on Add New Item after that Choose Data From left side vertical tab and In that select Dataset.

After Selecting Dataset open Toolbox and add the Datatable.
After adding Datatable Just add the Column on rightClick that columnname must be same as Database Column.

And In given Example I Used SQLConnection in asiEmployeeDAL Class and called necessary Methods for retriving Employee Data.
List<asiemployeedal> lstEmployee = asiEmployeeDAL.SelectAllEmployee()
Anil Vaghasiya 21-Jul-15 9:42am    
Hello,
Can You Display Your Code???
Member 11573837 21-Jul-15 9:52am    
helle,
this's same pic will show you my exemple i have use assisantate mode and this's my code in load

ReportDocument reportdocument = new ReportDocument();
reportdocument.Load(Server.MapPath("CrystalReport1.rpt"));
CrystalReportViewer1.ReportSource = reportdocument;
CrystalReportViewer1.DataBind();



http://www.mediafire.com/view/6whfhmxug36ck6u/etats1.JPG

http://www.mediafire.com/view/287w7547muoy7bk/etat2.JPG

http://www.mediafire.com/view/ynihgslrcj79cn2/etat3.JPG

sorry for being late
Member 11573837 21-Jul-15 10:06am    
hi Anil Vaghasiya,
do you have any idea !!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900