RSS 2.0
# Monday, January 25, 2010

A common issue that I’ve seen asked about with SQL Server Reporting Services (I’m using 2005 for this project) is to have a checkbox.  Have seen the references to using the wingding font for a textbox and altering the value with an iif statement.  Works fine for display in the viewer, but exporting pdf renders junk for it.  So I started using an image and setting the visibility.  Well, apparently when you add an image that determines the border for the cell, so when it’s set to hidden you get strange output:

image

Ok, so that’s not acceptable.

Couldn’t find any easy way to swap out images with an expression.  So what I finally ended up figuring out was to use a rectangle in the cell and add an image on top of that.  Doing that, the rectangle stays and renders it’s border and the image renders over top.  This gives the output I would expect.

 

image

So, why no report control to display a boolean value?

Monday, January 25, 2010 4:44:38 PM UTC  #    Comments [0] -
SQL Server Reporting Services
# Tuesday, January 12, 2010

So I’m working on a project now that requires the use of using SSRS 2005.  The data is based on rules that are in the business layer, so I wanted to use those objects rather than pulling from the database which would most likely require creating a set of tables just for this purpose and all the overhead of writing data temporarily only to pull it right back out again and then delete it.  Big waste.  Figured it can’t be that hard to use your own IEnumerable<T> data to populate with. I found several articles out there, but the one I based my code off of came from http://www.gotreportviewer.com/ and specifically this code sample.  Not difficult when you look at it – quite simple in fact.  I’m not going to regurgitate the code here, go read through their site and look through that example.  After reading through examples, I like to create my own scratch project and do the code myself to reinforce it. 

The one thing that got me was in setting up the DataSource.  Looking at the call it, it’s simple. The overload I used is the one that takes in a parameter named “name” of type string and one named “dataSourceValue” of type object.  When I see a parameter named “name” it seems to me to be an arbitrary name to be set by the developer.  The thing to note is that the name actually has to be the name of the type in the IEnumerable<T>.  In my case I have this in a Customer class:

  1. private List<Product> list;
  2. public List<Product> GetProducts()
  3. {
  4.     list = new List<Product>();
  5.     list.Add(new Product(1, "Product 1"));
  6.     list.Add(new Product(2, "Product 2"));
  7.     return list;
  8. }

 

And in the Page_Load event this code:

  1. Customer customer = new Customer();
  2. ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
  3. ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report1.rdlc");
  4. ReportViewer1.LocalReport.DataSources.Add(
  5.     new ReportDataSource("Product", customer.GetProducts()));
  6. ReportViewer1.LocalReport.Refresh();

 

Initially, since I figured the name property was arbitrary, I used “Products” rather than “Product” and was presented with the following error:

A data source instance has not been supplied for the data source 'Product'. I never found anything that mentioned the importance of the “name” parameter.

Hope this is helpful to someone else out there!

Tuesday, January 12, 2010 5:47:08 PM UTC  #    Comments [0] -
SQL Server Reporting Services
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
George Handlin
Sign In
Statistics
Total Posts: 51
This Year: 0
This Month: 0
This Week: 0
Comments: 9
All Content © 2012, George Handlin
DasBlog theme 'Business' created by Christoph De Baene (delarou)