Search code examples
vb.netreporting-servicesssrs-tablix

Can I use a method that returns a list of strings in SSRS report code as the headers in a tablix?


I have table that needs to contain 50 columns for each half hour in the day (+2 for daylight savings). So each column will be HH1, HH2, HH3... HH50.

I have written this piece of code in the report properties code section.

Function GetHH() As List(Of String)
    Dim headers As List(Of String) = new List(Of String)
    For index As Integer = 1 to 50
        headers.Add("HH" & index)   
    Next    
    return headers
End Function

Is there a way to use the output of this function as the headers of my tablix? Or will I need to add the headers to some sort of dataset in the database and add it from there?


Solution

  • The column group functionality would be well suited for this. As you mentioned, you would need to write a SQL statement to return these values in a dataset. Then you can set your column group to group on these values. This way your table always gets the right number of columns and you don't have to add them manually.