2012-04-19 59 views
1

RDLC(VS2010)を使用して、Webページ(MVC3)で簡単な出荷ラベルをPDFにレンダリングしています。 RDLC(ShipmentId)に渡す必要がある単一のパラメータがあります。そのパラメータを渡すと、渡すパラメータを表示するはずのテキストボックスを除いて、レポートが正しくレンダリングされます。レポートパラメータを表示するローカルのRDLCレポート

RDLCのテキストボックスの値は、 '= Parameters!ShipmentId.Value'に設定されています。問題はProcessingMode.Localを使用した場合のReportViewerはReportParametersを持つことができないということが判明し

shipment.ShipmentId = "123TEST"; 

    Warning[] warnings; 
    string mimeType; 
    string[] streamids; 
    string encoding; 
    string filenameExtension; 

    LocalReport report = new LocalReport(); 
    report.ReportPath = @"Labels\ShippingLabel.rdlc"; 
    report.Refresh(); 

    report.EnableExternalImages = true; 

    ReportParameter param = new ReportParameter("ShipmentId", shipment.ShipmentId, true); 
    report.SetParameters(param); 

    report.Refresh(); 

    byte[] bytes = report.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); 

    return new FileContentResult(bytes, mimeType); 

答えて

0

:ここ

は次のように私のコードが見えるものです。代わりに、コードを変更してパラメータの代わりにデータソースを使用しました。

 Warning[] warnings; 
     string mimeType; 
     string[] streamids; 
     string encoding; 
     string filenameExtension; 

     var viewer = new ReportViewer(); 
     viewer.ProcessingMode = ProcessingMode.Local; 

     viewer.LocalReport.ReportPath = @"Labels\ShippingLabel.rdlc"; 
     viewer.LocalReport.EnableExternalImages = true; 

     var shipLabel = new ShippingLabel { ShipmentId = shipment.ShipmentId, Barcode = GetBarcode(shipment.ShipmentId) }; 

     viewer.LocalReport.DataSources.Add(new ReportDataSource("ShippingLabel", new List<ShippingLabel> { shipLabel })); 
     viewer.LocalReport.Refresh(); 

     var bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); 
関連する問題