我需要幫助動態地在ReportViewer中添加圖像徽標。我從數據庫獲取該圖像,將其轉換爲Base64,然後我需要將其添加到的ReportViewer ...接下來這段代碼:如何動態地將圖片徽標添加到ReportViewer參數?
rpViewer.LocalReport.EnableExternalImages = true;
Company _company = db.Companys.Where(c => c.codCompany == c.codCompany).Single();
//first step
byte[] img = _company.imagem.ToArray(); // i get image from db
MemoryStream _ms = new MemoryStream(img);
string logo = Convert.ToBase64String(img); //convert to base64
// 2 step
List<ReportParameter> lstReportParams = new List<ReportParameter>();//Create params
lstReportParams.Add(new ReportParameter("Logo", logo));
lstReportParams.Add(new ReportParameter("LogoMimeType", "image/png"));
// Doesn't work here (see error below)
this.rpViewer.LocalReport.SetParameters(lstReportParams);
this.rpViewer.RefreshReport();
錯誤:
{"An error occurred during local report processing."}
{"An attempt was made to set a report parameter 'Logo' that is not defined in this report."}
在Rldc:
MIMEType =Parameters!LogoMimeType.value
Value ="System.Convert.FromBase64String(Parameters!Logo.Value)"
它爲什麼不起作用?
爲什麼不識別參數?
我可以在ReportViewer中加載該圖像。
嗨, 我需要拍一張db中的圖片,這是公司的標誌,並在報告中顯示。 RLDC中的這個參數可以嗎? MIMEType =參數!LogoMimeType.value值 Value =「System.Convert.FromBase64String(Parameters!Logo.Value)」 謝謝.. – user95542 2009-07-19 16:39:24