Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 asp net forms for Web, on the second I have a crystal report viewer control, I use VB .Net 2008. I want to set the source of crystalreportviewer from the First form.
VB
Dim poli As String
      Dim poli2 As String
      Dim poli3 As String
      Dim textbox1 As TextBox
      Dim textbox2 As TextBox
      Dim textbox3 As TextBox
      poli = textbox1.Text
      poli2 = textbox2.Text
      poli3 = textbox3.Text
      Dim rptDoc As New ReportDocument
      rptDoc.Load(Server.MapPath("CrystalReport.rpt"))
      rptDoc.SetParameterValue("My Parameter", poli)
      rptDoc.SetParameterValue("My Parameter 2", poli2)
      rptDoc.SetParameterValue("My Parameter 3", poli3)
      Response.Redirect("Default2.aspx")

tried to insert from default2.aspx the crystalreportviewer source as rptdoc but there is no Connection between 2 forms, I am a newbie how can I make a form's control PUBLIC in asp?
Posted

1 solution

You can't do it this way. You're mixing up windows forms and web forms. In the web, your form does not exist until someone browses to the page url. Then the server parses it, runs any VB# code you have, and then sends html back to the client and disconnects. So, you can't share between pages because they don't exist in memory.

You can pass information from form1 to form2 through the querystring. Response.Redirect("form2.aspx?id=2") for example and then form2 can check for id in the querystring and do what it needs to.
 
Share this answer
 
v2
Comments
Member 3892343 25-Jun-15 5:23am    
and how do i pass parameters like form2?id=2&source=rpt
ZurdoDev 25-Jun-15 7:30am    
Sorry, I missed the .aspx part of the url.

However, you can't pass the entire datasource through the querystring. You can only do strings.

You could store the datasource in the session first and then redirect to form2. Or, you may want to reconsider how you are doing things.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900