Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

LinqDataSource does not work with Microsoft.Reporting.LocalReport

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 1.14 KB  |  views: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Creating report
  2.         Microsoft.Reporting.WebForms.LocalReport report = new Microsoft.Reporting.WebForms.LocalReport();
  3.         report.ReportPath = Request.PhysicalApplicationPath + @"pathToreport.rdlc";
  4.         report.DisplayName = "Ttile";
  5.  
  6.         //Setting the data
  7.         //SetMyLinqDataSource();
  8.         myLinqDataSource.WhereParameters.Add(new Parameter("bla", avalue));
  9.         myLinqDataSource.Where = "field1 = @bla";
  10.         report.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("MyDataSetName", myLinqDataSource));
  11.  
  12.         //delivering to web user
  13.         Microsoft.Reporting.WebForms.Warning[] warnings;
  14.         string[] streamids;
  15.         string mimeType;
  16.         string encoding;
  17.         string extension;
  18.         //Here the databind should happen
  19.         byte[] bytes = report.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
  20.  
  21.         Response.Clear();
  22.         Response.ContentType = "application/pdf";
  23.         Response.AddHeader("content-disposition", "attachment; filename=Report.pdf");
  24.         Response.Flush();
  25.         Response.BinaryWrite(bytes);
  26.         Response.Flush();
clone this paste RAW Paste Data