[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 572
  • Last Modified:

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

0
goffer
Asked:
goffer
  • 3
  • 3
1 Solution
 
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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
 
gofferAuthor 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

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now