Sos

Sos

  • NA
  • 63
  • 886

C# Showing pictures from "DataGridView" on RDLC report image

Feb 8 2021 9:44 PM
I want to display the selected image from datagridview in the image RDLC report .
 
I tried with this code but it doesn't work .
 
Not working :(
  1. private void btnPrint_Click(object sender, EventArgs e)  
  2. {  
  3. frmPrint frm = new frmPrint();  
  4. // Datagrid opcije record set  
  5. frm.reportViewer1.LocalReport.DataSources.Clear();  
  6. frm.reportViewer1.LocalReport.ReportEmbeddedResource = "XmlView.Report1.rdlc";  
  7. frm.reportViewer1.LocalReport.EnableExternalImages = true;  
  8. DataGridViewCell dgcell = gvData.SelectedRows[0].Cells[12];  
  9. if (dgcell.Tag != null)  
  10. {  
  11. string imgCode = dgcell.Tag.ToString();  
  12. byte[] bytes = Convert.FromBase64String(imgCode);  
  13. //using (MemoryStream m = new MemoryStream(bytes)) ;  
  14. ReportParameter[] parms = new ReportParameter[1];  
  15. parms[0] = new ReportParameter("txtImage", imgCode);  
  16. frm.reportViewer1.LocalReport.SetParameters(parms);  
  17. frm.reportViewer1.RefreshReport();  
  18. frm.reportViewer1.LocalReport.Refresh();  
  19. frm.ShowDialog();  
  20. }  
  21. }  
Thanks in Advance

Answers (6)