title: How to dynamically set Telerik Report Picture box based on passed in parameter
body: <p>I am generating a <code>Telerik</code> report in an <code>MVC</code> application. The report is being rendered straight to pdf format, not using a <code>Report Viewer</code>. I think I am passing the parameter correctly from the controller but I can not figure out how or where to get the parameters value in the report code behind when the report is being rendered. I want to dynamically populate a picture box depending on the value of the passed in parameter using a <code>User Function</code>. </p>
  
  <p>Here is my Controller code that opens the report. If I hard code the buyer variable I get the correct image to display in the picturebox:</p>
  
  <pre><code> public ActionResult PrintPoReport()
      {
          byte[] contents;
          Telerik.Reporting.Processing.RenderingResult result;
  
          using (var reportDocument = new LogisticsReports.Report1())
          {
              var buyerID = "999999";  //hard code buyerId for testing
              var irs = new InstanceReportSource();
              irs.ReportDocument = reportDocument;
  
              irs.Parameters.Add(new Parameter("Buyer", "buyerID")); // parameter to determine which jpg will populate picture box. **Never gets to Report1** 
              Telerik.Reporting.Processing.ReportProcessor rp = new Telerik.Reporting.Processing.ReportProcessor();
              result = rp.RenderReport("PDF", irs, null);
              contents = result.DocumentBytes;
          }
  
          return File(contents, "application/pdf", "P0 #" + id + ".pdf");
      }
  </code></pre>
  
  <p>The Code Behind for the report:</p>
  
  <pre><code>public partial class Report1 : Telerik.Reporting.Report
  {
      public Report1()
      {
  
          InitializeComponent();
  
          var buyer = "999999"; //hard coded for testing...this works!
          //Need to capture the passed in parameter here
          if (buyer == "111111"){
  
              this.pictureBox1.Value = "http://www.arctecalaska.com/images/signatures/111111.bmp";
          }
          if (buyer == "999999")
          {
  
              this.pictureBox1.Value = "http://www.arctecalaska.com/images/signatures/Ike.jpg";
          }
  
  
       }
     }
  }
  </code></pre>
  
  <p>The problem is that the buyer parameter I send from the Controller never actually makes it to the report. During debug the report InitializeComponent() runs as soon as the code hits the line: </p>
  
  <pre><code>var reportDocument = new LogisticsReports.Report1 
  </code></pre>
  
  <p>I need to be able to capture and evaluate the passed in parameter before the report renders but I don't see how to do that. Any Ideas?</p>