We help IT Professionals succeed at work.
Get Started

Loop through string?

jay-are
jay-are asked
on
442 Views
Last Modified: 2012-05-09
Hello Experts:

I have a string value that looks like this:  Demo1,Demo2,Demo3
There can be just 1 value with no commas all the way up to nine values all separated by commas.

I'd like to use these values for parameters and pass them using a reportviewer.  How do I convert the values Demo1,Demo2,Demo3 etc into some sort of parameter list and pass it to the reportviewer?

The attached code gives me the error:  Unable to cast object of type 'System.String' to type 'Microsoft.Reporting.WebForms.ReportParameter'.

'cid is the string value: Demo1,Demo2,Demo3 etc.
            Dim aryCID() = cid.Split(",")
            Dim params As ReportParameter
            For i As Integer = 0 To aryCID.Length - 1
                params = aryCID(i)
            Next
            ReportViewer1.ServerReport.SetParameters(params)

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 14 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE