Ian Pendlebury
Ian Pendlebury

Reputation: 85

Report Designer in VS Community 2015

I'm a seasoned MS Access developer trying to learn C# and I'm finding formatting reports to be really difficult compared to how easy MS Access is.

I couldn't get anything useful out of the report wizard, but I've now got my head around creating a report manually. So ok I now have a basic report showing a customer listing, with a title in the page header section.

So now what I want to do is change the title at runtime. For example if I filter the dataset to only show UK customers who have bought goods this year, I want to change the title in order to explain what is being listed: "UK Customers who bought goods this year".

In MS Access I can use the report pageheader OnFormat event to do things like this. Can this be done in C#?

Upvotes: 0

Views: 651

Answers (2)

jt000
jt000

Reputation: 3236

Reporting Services uses visual basic for the expression language, so you can set the title to something like ="foo #" & (3+3) to get a value of "foo #6". Additionally, you can use parameters as you mentioned in your answer by setting the title to =Report.Parameters!Title.Value (assuming you have a parameter named "Title").

If you'd like to use C#, then unfortunately you can only do this via a custom assembly, which is not the easiest thing in the world to get set up.

For more information on embedding code in a SSRS report, take a look at this page on MSDN: https://msdn.microsoft.com/en-us/library/ms159238(v=sql.120).aspx

Upvotes: 1

Ian Pendlebury
Ian Pendlebury

Reputation: 85

I've managed to sort this out myself. In the DataSet for my Report I added a column to the TableAdapter query. Select @Title as Title, Customers.CustomerCode etc... In the Report I added a TextBox for the Title and bound it to the title field in the dataset. Then when my report opens, I can supply the title as a parameter when the DataSet Table is filled.

Upvotes: 1

Related Questions