Showing pictures from "DataGridView" on RDLC report image

Backo

New member
Joined
Feb 8, 2021
Messages
2
Programming Experience
Beginner
I want to display the selected image from datagridview in the image RDLC report .
I tried with this code but it doesn't work .


Screenshot_1.png




C#:
 private void btnPrint_Click(object sender, EventArgs e)
        {
            frmPrint frm = new frmPrint();

            // Datagrid opcije record set
            frm.reportViewer1.LocalReport.DataSources.Clear();

            frm.reportViewer1.LocalReport.ReportEmbeddedResource = "XmlView.Report1.rdlc";
            frm.reportViewer1.LocalReport.EnableExternalImages = true;



         

            DataGridViewCell dgcell = gvData.SelectedRows[0].Cells[12];
            if (dgcell.Tag != null)
            {
                string imgCode = dgcell.Tag.ToString();
                byte[] bytes = Convert.FromBase64String(imgCode);

                //using (MemoryStream m = new MemoryStream(bytes)) ;

            ReportParameter[] parms = new ReportParameter[1];
            parms[0] = new ReportParameter("txtImage", imgCode);



            frm.reportViewer1.LocalReport.SetParameters(parms);
            frm.reportViewer1.RefreshReport();
            frm.reportViewer1.LocalReport.Refresh();

            frm.ShowDialog();
           }
        }



Thanks in Advance

Mod edit : Post thumbnails not massive images
 
Last edited by a moderator:

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,554
Location
Sydney, Australia
Programming Experience
10+
Do RDLC reports accept base-64 text as representations of images? I don't really use them much so I don't know. Have you checked specifically and confirmed that they do?
 
Top Bottom