Change Crystal report file using radio buttons

I would like to be able to change the Crystal Report Source Filename to the value of a radio button list.  I have the reports built, all I need help with is how to accomplish changing the which report is used when a radio button is changed.  I tried the code below hoping that it was that simple, but when I change the radio button the Crystal Report Viewer says Error Loading Report.  
Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
        CrystalReportViewer1.ReportSource = RadioButtonList1.SelectedValue
    End Sub

Open in new window

gofferAsked:
Who is Participating?
 
gofferConnect With a Mentor Author Commented:
I figured it out.  I  used the code below and set the radio button values to crystalreportsource1 and crystalreportsource2 and made a different report source for each report and now when i select the radio button it changes.

    Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
        CrystalReportViewer1.ReportSourceID = RadioButtonList1.SelectedValue
 
    End Sub

Open in new window

0
 
Mortaza DoulatyCommented:
Change AutoPostBack property of your radiobuttonlist to True.
0
 
gofferAuthor Commented:
I tried that, still the same issue, I already had a button that causes postback and have the same issues.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
gofferAuthor Commented:
I'm basically doing the same thing suggested in that link, the values of the radio button are set to the path of the filename.
0
 
Mortaza DoulatyCommented:
Try to use:

Server.MapPath(YOUR REPORTS PATH RELATIVE TO WEB SITE, e.g: reports\myrep.rpt)

for the path of the report file in your code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.