none
Passing values to a multi valued parameter RRS feed

  • Question

  • Hi Friends,

    Please help me in solving this problem.
    My Problem is ..

    I am working with a report which has to show some multiple values for a parameter and those values are to be displayed in a column one under the other.

    As there is no DataSet for the report ..the ReportViewer is not allowing to place a Table control on the  report.rdlc.So I was trying to use this multivalue parameter.I have taken a parameter to which I have set Multivalue property as true.

    My problem is ..How to assign values (using VB.Net) to this multivalued parameter   in runtime.

    Please help me as ASAP.

    Thanks in advance,
    Sowjanya.
    Friday, September 12, 2008 5:07 AM

Answers

  • Hi
        Sorry but one line I will write in c# ;]. Setting multivalued parameter:
    reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { new Microsoft.Reporting.WinForms.ReportParameter("param01", new String[] { "a", "b", "c" }) });

    As for displaying it in report first you need to add this function to your report

    Public Function ArrFormat(ByVal txtarr as Array) As String
            Dim txt As String
            Dim txtvar As String
            txt = ""
            For each txtvar in txtarr
                txt = txt + txtvar + vbCrLf
            Next
            Return txt
        End Function

    And next you need to add text box to your report with this expression
    =Code.ArrFormat(Parameters!param01.Value)

    Ofcourse you can have different parameter name, here it is 'param01'.


    everything is a matter of probability...
    Friday, September 12, 2008 2:34 PM
  • Btw, another way of displaying the contents of a multi-value parameter in a textbox in the report is:
    =Join(Parameters!Param1.Value, ",")

    You might also want to read documentation for more information on how to use multi-valued parameters inside a report: http://msdn.microsoft.com/en-us/library/aa337292.aspx

    Hope this helps,
    Robert
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, September 12, 2008 4:23 PM
    Moderator

All replies

  • Hi
        Sorry but one line I will write in c# ;]. Setting multivalued parameter:
    reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { new Microsoft.Reporting.WinForms.ReportParameter("param01", new String[] { "a", "b", "c" }) });

    As for displaying it in report first you need to add this function to your report

    Public Function ArrFormat(ByVal txtarr as Array) As String
            Dim txt As String
            Dim txtvar As String
            txt = ""
            For each txtvar in txtarr
                txt = txt + txtvar + vbCrLf
            Next
            Return txt
        End Function

    And next you need to add text box to your report with this expression
    =Code.ArrFormat(Parameters!param01.Value)

    Ofcourse you can have different parameter name, here it is 'param01'.


    everything is a matter of probability...
    Friday, September 12, 2008 2:34 PM
  • Btw, another way of displaying the contents of a multi-value parameter in a textbox in the report is:
    =Join(Parameters!Param1.Value, ",")

    You might also want to read documentation for more information on how to use multi-valued parameters inside a report: http://msdn.microsoft.com/en-us/library/aa337292.aspx

    Hope this helps,
    Robert
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, September 12, 2008 4:23 PM
    Moderator