none
Setting Parameter Labels in Local Mode RRS feed

  • Question

  •  

    I've created a windows app that reads in a directory of .rdl files, allows the user to select one, then creates a parameter form, passes the parameters to a RV control (+ datasets yadda, yadda) and displays the report in local mode.

     

    (VB.Net)

     

    The problem I have is this - Some of the reports use parameters with multi Valid Values (which I can read both from hard-coded and query based defaults), which is not a problem until I go to re-insert the selected value back into the report.

     

    I can get the value from the drop down list into the report OK, but can't for the life of me figure out how to get the Label from the drop down back into the report.

     

    The report can use Parameters!MyParameter.Label and in the BI Dev environment it passed labels back OK, so how do I apply the Label to the parameter ????

     

    My code so far for retrieving the values from each control and sticking it back into the parameter

    (Note: ValueListItem is a structure containing a value and a label.)

    (Note: ERHelper.getReportDetail is a function that returns a value from the .rdl file based on an xPath query)

     

     

    Dim rpParam As ReportParameterInfo

    Dim rpNewParam As ReportParameter

    Dim rl As New List(Of ReportParameter)

     

    For Each rpParam In rpTheReport.LocalReport.GetParameters

    Dim stParamPath As String = "//def:ReportParameters/def:ReportParameter[@Name='" & rpParam.Name & "']"

    Dim bIsHidden As Boolean = (ERHelper.getReportDetail(rpTheReport.LocalReport.ReportPath, stParamPath & "/def:Hidden") = "true")

    rpNewParam = New ReportParameter()

    rpNewParam.Name = rpParam.Name

     

    If (Not rpParam.ValidValues Is Nothing) Or ERHelper.getReportDetail(rpTheReport.LocalReport.ReportPath, stParamPath & "/def:ValidValues/def: DataSetReference/def: DataSetName") <> "" Then

    'Combo Box

    Dim vli As ValueListItem

    vli = CType(pnlTable.Controls(rpParam.Name), ComboBox).SelectedItem()

    rpNewParam.Values.Add(vli.value)

    *** NEED SOMETHING HERE TO PUT THE LABEL IN THE PARAMETER ***

    Else

    'Other Control Type

    Select Case rpParam.DataType

    Case ParameterDataType.Boolean

    rpNewParam.Values.Add(IIf((CType(pnlTable.Controls(rpParam.Name), CheckBox).Checked), "True", "False"))

    Case Else

    rpNewParam.Values.Add(pnlTable.Controls(rpParam.Name).Text)

    End Select

    End If

    rl.Add(rpNewParam)

    Next

    rpTheReport.LocalReport.SetParameters(rl)

     

    Me.Close()

     

    Friday, November 16, 2007 12:50 AM

All replies

  • Further to this:

     

    I've been spending some time with ye olde' Object Browser and I cannot find anywhere where the labels of a multi value parameter list is exposed for developer use.

     

    I don't want to give up hope of solving this, but I fear that I might have to, and try a different approach.

     

    Hmmm - something with a custom function in the report definition to resolve a value from a dataset?  Eww!

     

    Help!!! 

    Friday, November 16, 2007 5:39 AM
  • Help again.  I REALLY need an aswer of some sort on this even if it's "Sorry, but you just cannot make your app do what our server can do and that's final" so I can give up and research other technologies.

     

    I've worked out that if the ValidValues for a parameter are static in the .rdl then it resolves the label from the value passed to the paramer at run time, but it does not seem to be possible to populate ValidValues at runtime from a dataset using reportViewer in local mode.

     

    Can anyone else confirm this, or am I missing something incredibly basic so that we can all say "Ahh - that was it" and I can finally get some sleep.

     

    The diet-cola is starting to run out.

     

     

    Monday, November 19, 2007 6:12 AM
  • Ammusionist:

     

    I posted a similar question back in August and never got any replies...not even to how to get this added to the list of future enhancements if it doesn't work now.  It seems like a hole in the parameter processing...they obviously are able to do this when running remotely.

     

    Before I go about re-inventing the wheel did you come up with any generic solution to this problem or do you handle each need uniquely?

     

    Thanks in advance.

     

    GlennL

     

    Friday, February 1, 2008 3:25 PM
  • Ok, well, I don't know about an ideal functional way, and since nobody is giving you an answer, here is a workaround.

     

    Create a parameter that just stores the label value,

     

    so you'd create the parameters in the .rdlc

     

    firstParam

    firstParamLbl

    secondParam

    secondParamLbl

     

    and so on...

     

    then in your report just use the expression:  Cstr(Parameters!firstParamLbl.Value) + " " + Cstr(Paramaters!firstParam.Value)

     

     

    probably not a great solution, but it's functional

    Friday, February 1, 2008 6:03 PM
  • Blast2Hell:

     

    Thanks for the response.  I tried something like that but couldn't get the lbl parameters to populate (remember that in local mode the app is responsible for the parameter handling and to make things more difficult mine is a generic app capable of processing (theoretically) any rdl (with rdl I get both the report definitions as well as the sql/dataset info)). 

     

    I'm currently trying it with hidden parameters where the "default value" is from a query that simply returns the passed in parameter (e.g. select @paramlbl as paramlbl) where @paramlbl is defined as =Parameters!firstParamCombobox.Label.  Not a good use of sql/resources but it's an infrequent, fast hit to the database.  This almost works except that the ReportParameterInfo object for the firstParamCombobox shows some odd dependent info - perhaps having an issue with the weird sql statement. 

     

     I'll keep trying...

     

    GlennL

    Friday, February 1, 2008 8:14 PM
  • yeah, I'm doing something similar, I have one page designed to handle all my reports, in this case, about 64 different .rdlc files.

     

    And the user can dynamically set up to two layers of group or three levels of sorting, both descending and ascending.

     

    I had a problem where they'd select something to group on, but I wanted to display what they were grouping on, as opposed to just writing static text such as "group 1" or "group 2"

     

    So I decided to use parameters, purely as a label.   And here is the code I put in my code behind for the page

     

    ReportParameter group1 = new ReportParameter("Group1Param", PrimaryGroupDrop.SelectedItem.Text);

    ReportParameter group2 = new ReportParameter("Group2Param", SecondaryGroupDrop.SelectedItem.Text);

     

    ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { group1, group2 });

     

    where PrimaryGroupDrop, and secondarygroupdrop are dropdowns the user selects grouping values from.

     

    then in my report, to call these values, I simply use the expression

     

     

    =Parameters!Group1Param.Value

     

    and

     

    =Parameters!Group1Param.Value

     

     

    so to display the value you passed in, call the value property, not label

     

     

     

     

    Friday, February 1, 2008 8:24 PM
  • Dear Blast2Hell,

     

    I want to do the same thing, but I´m not succesfull. Can you please contact me (per mail or MSN anmichael@hotmail.com or via Skype "mykey0815" )? I have some questions to you.

     

    I´m a VB.NET programmer and i will write a usercontrol that can handles the reports dynamicly. I have some Ideas and maybe we can adding our Ideas to one great solution

     

    Thank you for your response

    MyKey0815

    Saturday, February 2, 2008 10:54 AM
  • you can just post here, or send an email to blast2hell@gmail.com and I'll see if I have any answers for you.  Thanks

     

    Sunday, February 3, 2008 3:36 PM
  • Dear all,

     both in Microsoft.Reporting.WebForms.ReportParameterInfo and in ReportService.ReportParameter (SSRS) there is a field called Promt, which shows parameter label. You can also change parameter name to be more like a label.
    The label you are talking is not a parameter label but rather a label for the value in the list. I don't understand, however, why would you want to pass label back to the report, the report knows it already, you just pass values. So I am not sure if it answers your question.

    But I can understand you struggles as I currently ran into a problem with Dependents and Dependencies property which does not actully show dependents or dependencies but rather succeeding and preceeding parameters to a current parameter in report definition. It was a bummer.

    I also have a web app that goes into SSRS reads available reports, lets user select one, and creates a form for parameters. The actual preview I dump into iFrame in some other user specified format, instead of report viewer, so that user can print using things already avail on the machine and without installing report viewer printing control, which many users can't due to lack of privilages.

    Happy coding.
    ------------------------------

    Ok. I got what you are trying to do. If you want see parameters value labels in the report itself for multi valued parameters you need to use Join function to concatenate selected labels. By default you get Parameters!MyParam(0). Join function will concatenate array into a signle delimited string. Delimiter is a second argument in Join function. Like so: Join(Parameters!MyParam.Label, ",") where MyParam is a multivalued parameter.
    • Edited by jhhhj Thursday, July 9, 2009 6:51 PM
    • Proposed as answer by MyKey0815 Sunday, January 23, 2011 1:28 PM
    Thursday, July 9, 2009 6:04 PM
  • ... Ok. I got what you are trying to do. If you want see parameters value labels in the report itself for multi valued parameters you need to use Join function to concatenate selected labels. By default you get Parameters!MyParam(0). Join function will concatenate array into a signle delimited string. Delimiter is a second argument in Join function. Like so: Join(Parameters!MyParam.Label, ",") where MyParam is a multivalued parameter.

    I don't think we are able to display Labels for ReportViewer in Local Mode regardless of whether or not the parameter is multi-valued.  I believe this has to do with SetParameters() only taking Values into account.  If you are seeing otherwise, please let me know.

    If this is the case that this functionality is missing in Local Mode, can anybody confirm whether or not the ability to display parameter Labels exists in Remote (Server) mode?
    • Proposed as answer by MyKey0815 Sunday, January 23, 2011 1:28 PM
    Monday, December 7, 2009 1:00 PM