SSRS 2008 R2 - access entire dataset from custom code
Hi NG
I use the following expression on a report label. The parameter is a multi-valued parameter, that has it's visibility set to "internal". It has its available values set to the HMG dataset, with a valid value and label field. It also
has its default values set to read from the same dataset, ensuring that there is a list of valid values available.
=Join(Parameters!HeaderMediaGroups.Label, "/")
However, when the source dataset is empty, the paramtere does not have any data to load, and therefor prevents the report from loading.
I would like to not use a parameter, but rather have a custom code function to loop through the dataset and return a delimited string for display. Something along these lines ...
Public Function MakeList(ByVal items As Object(), ByVal Sprtr As String) As String
If items Is Nothing Then
Return String.Empty
End If
Dim builder As System.Text.StringBuilder = New System.Text.StringBuilder()
Dim blnIsNew As Boolean = True
For Each item As Object In items
If item.ToString().Trim().Length > 0 Then
If Not blnIsNew Then builder.Append(Sprtr)
builder.Append(item)
blnIsNew = False
End If
Next
Return builder.ToString()
End Function
Regards Des Norton
January 24th, 2011 4:31am
My current hack is to add an extra field to the dataset, named [Dummy], which has a value of 1 for all records.
I then call the custo code as follows:
=Code.MakeList(LookupSet(1, Fields!Dummy.Value, Fields!Name.Value,
"HMG"),
"/")Regards Des Norton
Free Windows Admin Tool Kit Click here and download it now
January 24th, 2011 5:06am