Click here to Skip to main content
15,038,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone, I have a small problem in my rdlc report. All works fine report gets generated in required format, but the only thing is the images are not displaying.They are placed in a particular folder.How to display them in rdlc report, all other data is displayed from database but only images are not displayed.Please help.

C#
dbprocess db = new dbprocess();
   protected void Page_Load(object sender, EventArgs e)
   {
       if (Convert.ToString(Session["usern"]) == "")
           Response.Redirect("login.aspx");
       try
       {
           ReportViewer rpt = new ReportViewer();
           SqlCommand cmd = new SqlCommand();
           SqlConnection conn = new SqlConnection();
           conn = db.openconn();
           cmd.Connection = conn;
           DataSet ds1 = new DataSet();
           //cmd.Parameters.AddWithValue("@tbl", Session["gettable"].ToString());
           //cmd.Parameters.AddWithValue("@instno", Session["usern"].ToString());
           //cmd.Parameters.AddWithValue("@sub_code", Session["sub_code"].ToString());
           //cmd.Parameters.AddWithValue("@c_id", Session["courseid"].ToString());
           //cmd.Parameters.AddWithValue("@col_code", Session["Col_Code"].ToString());

           //cmd.Parameters.AddWithValue("@mode", "report1");
           cmd.Parameters.AddWithValue("@appid", Session["app_id"]);
           if(Convert.ToString(Session["examtype"])=="22222")
               cmd.Parameters.AddWithValue("@mode", "report1");
           else if(Convert.ToString(Session["examtype"])=="11111")
               cmd.Parameters.AddWithValue("@mode", "report2");


           cmd.CommandType = CommandType.StoredProcedure;
           cmd.CommandText = "[RegisterCard_report]";
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           da.Fill(ds1);
           cmd.Parameters.Clear();


           ReportDataSource obj1 = new ReportDataSource("RCBcom_Dataset", ds1.Tables[0]);
           //ReportDataSource obj2 = new ReportDataSource("DataSet2", ds1.Tables[1]);
           //ReportDataSource obj3 = new ReportDataSource("DataSet3", ds1.Tables[2]);


           //string nm = ds1.Tables[2].Rows[0][1].ToString();

           ReportViewer1.LocalReport.DataSources.Add(obj1);
           //ReportViewer1.LocalReport.DataSources.Add(obj2);
           //ReportViewer1.LocalReport.DataSources.Add(obj3);

           if (Convert.ToString(Session["examtype"]) == "22222")
                ReportViewer1.LocalReport.ReportPath = "RCBComreport.rdlc";
           else if (Convert.ToString(Session["examtype"]) == "11111")
               ReportViewer1.LocalReport.ReportPath = "RCBAreport.rdlc";

          // ReportViewer1.LocalReport.ReportPath = "report1.rdlc";
           ReportViewer1.LocalReport.Refresh();
           //-------- Print PDF directly without showing ReportViewer ---
           Warning[] warnings;
           string[] streamids;
           string mimeType;
           string encoding;
           string extension;
           byte[] bytePdfRep = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
           Response.ClearContent();
           Response.ClearHeaders();
           Response.Buffer = true;
           Response.ContentType = "application/pdf";
           Response.AddHeader("content-disposition", "attachment;filename=\"" + Session["usern"].ToString() + ".pdf" + "\""); //Give file name here
           Response.BinaryWrite(bytePdfRep);
           Session["status"] = 5;
       }
       catch { }

   }
Posted

1 solution

Are you storing images in database or just paths to images?

First , you need to take care few things if you are fetching your images from database then you need to set image source property to "Database" but if image is not saved in the database, but only the path to it then changed it to "External".
Check that property of Image.
Second, Can you verify that the image URL in the rendered report is correct? E.g. if you copy image URL from the report - does it match the real path?
Just to confirm if you copy that URL and paste into a browser address bar - you do see the image?
   

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