ToReportInASP.Net, I am usingSAPCrystalReport.
Whythe Printbutton
on theToolbardoes not work?so I can notprint
reportsthatshow.
Is it becausein
the SubPage_Load
I use thecommand"If NotPage.IsPostBackThen"
If Ido notuse,If NotPage.IsPostBack
Then,latercode thatinsideSub
Page_Load(senderAs Object,eAsEventArgs)will be executedrepeatedly.
So Istopped it.so justexecutedonce, when
WebFormis loaded
atfirst.
For more details,belowIshow thesourcecodethat I use.
Sub Page_Load(sender As Object, e As EventArgs)
If Not Page.IsPostBack Then
Try
myConnection = New MySqlConnection(".....;")
cmd.CommandText = "insert into table1(...) select ... from tbtemp where KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
cmd.CommandType = CommandType.Text
strSql = "select ... from tbtemp WHERE KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
myDataAdapter = New MySqlDataAdapter(strSql, myConnection)
myDataAdapter.Fill(dsK, "DTKwitansi")
If dsK.Tables("DTKwitansi").Rows.Count > 0 Then
rpt = New crKwitansi
rpt.SetDataSource(dsK)
Dim crPFDs As ParameterFieldDefinitions
Dim crPFD As ParameterFieldDefinition
Dim crPVs As New ParameterValues
Dim crPDV As New ParameterDiscreteValue
frangky_koe
Member
1 Points
21 Posts
Why in the Crystal Report Print Button does not work? Is it because the use Page.IsPostBack?
Jul 24, 2012 04:01 PM|LINK
Hi Experts,,
To Report In ASP.Net, I am using SAP Crystal Report. Why the Print button on the Toolbar does not work? so I can not print reports that show.
Is it because in the Sub Page_Load I use the command "If Not Page.IsPostBack Then"
If I do not use, If Not Page.IsPostBack Then, later code that inside Sub Page_Load (sender As Object, e As EventArgs) will be executed repeatedly. So I stopped it. so just executed once, when Web Form is loaded at first.
For more details, below I show the source code that I use.
Sub Page_Load(sender As Object, e As EventArgs)
If Not Page.IsPostBack Then
Try
myConnection = New MySqlConnection(".....;")
cmd.CommandText = "insert into table1(...) select ... from tbtemp where KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = myConnection
myConnection.Open()
cmd.ExecuteNonQuery()
strSql = "select ... from tbtemp WHERE KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
myDataAdapter = New MySqlDataAdapter(strSql, myConnection)
myDataAdapter.Fill(dsK, "DTKwitansi")
If dsK.Tables("DTKwitansi").Rows.Count > 0 Then
rpt = New crKwitansi
rpt.SetDataSource(dsK)
Dim crPFDs As ParameterFieldDefinitions
Dim crPFD As ParameterFieldDefinition
Dim crPVs As New ParameterValues
Dim crPDV As New ParameterDiscreteValue
crPDV.Value = Session("NamaUser").ToString
crPFDs = rpt.DataDefinition.ParameterFields
crPFD = crPFDs.Item("pNamaUser")
crPVs.Clear()
crPVs.Add(crPDV)
crPFD.ApplyCurrentValues(crPVs)
CrystalReportViewer1.ReportSource = rpt
cmd.CommandText = "delete from tbtemp where KodeKantorCabang='" & Session("KodeKantorCabang") & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = myConnection
cmd.ExecuteNonQuery()
myConnection.Close()
End If
Catch ex As MySqlException
Response.Write("My Sql Exception: " & ex.Message)
End Try
End If
End Sub
suresh dasar...
Contributor
3606 Points
743 Posts
Re: Why in the Crystal Report Print Button does not work? Is it because the use Page.IsPostBack?
Jul 25, 2012 04:12 AM|LINK
hi frangky,
check this link
http://www.aspdotnet-suresh.com/2012/02/crystal-report-not-showing-data-when.html
Please "Mark as Answer" If post helps you