Event Handler

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF ReportWriter for COM/ActiveX (v1)  /  Event Handler

DynamicPDF ReportWriter for COM/ActiveX (v1) Forum

 Aug 27 2007 3:21 PM
I am using ReportWriter 1.6.0 from an ASP.Net application.  The ASPX samples that came with 1.6.0 do not show a sample of event handling.  Is there a sample of event handling available for reference.

Thanks, David.
 Aug 27 2007 4:03 PM
Posted by a ceTe Software moderator
Hello David,

We do not have any sample example that shows handling events using the ASPX examples. We do have ASP example that shows how to do event handling.

ceTe Software Support Team
 Aug 27 2007 4:07 PM
Could you show in a reply post how you would code an OnDraw event handler?

 Aug 27 2007 5:29 PM
Posted by a ceTe Software moderator

Following is the sample code taken from the Invoce_Events ASP example.

Function LineTotal_OnDraw( TextArea )
    Dim intLineTotal
    intLineTotal = m_objReport.Recordset("UnitPrice") *    m_objReport.Recordset("Quantity")
    m_intSubTotal = m_intSubTotal + intLineTotal
    TextArea.Text = FormatNumber(intLineTotal)
End Function

ceTe Software Support Team
 Aug 28 2007 12:18 PM
Got that part.  What would the OnDraw call look like since ASP.NET does not support "Set" or "GetRef"?  Could you show me what that would look like within the SetBodyObj Sub?

Thanks for all of your help.
 Aug 28 2007 1:08 PM
Posted by a ceTe Software moderator

In ASP.NET the way to call events is using the sample lines below:

body.OnDraw += new OnDrawEventHandler( On_Draw );

private void On_Draw( object sender, OpeningRecordSetEventArgs e )
     // Add event handling code

ceTe Software Support Team
 Aug 28 2007 4:13 PM
I think I was going down the wrong path and trying to make this harder than it is.  At the end of my report in SectionFooter sub I am wanting to show a total number of records process. (Possibly number of records in recordset would even work)  Is there a way to count the number of records or show the total records at the end of my report in the SectionFooter.  I am using ASP.Net with Visual Basic as code behind language.

Thanks again for any help.

 Aug 28 2007 5:24 PM
Posted by a ceTe Software moderator

You can modify the query to use the Count(*) and store that value in a variable and then display it in the SectionFooter using the AddLabel method.

You can also get the count using the RecordSet object using sample code below:

Dim objRS As ADODB.Recordset
'Store the result in a recordset
Set objRS = objCom.Execute
'Open the recordset
Do While Not objRS.EOF
   'Increment a counter   

ceTe Software Support Team
 Aug 28 2007 5:43 PM
You may have just put me on the right track.  I already had a Count(*) variable in by recordset.  I was using an AddRecordBox, referencing the variable, in the SectionFooter and it worked perfect as long as I had records.  When my query did not select any records I received an EOF exception.  I was not for sure how to reference the variable from an AddLabel. 
 Aug 29 2007 8:15 AM
Posted by a ceTe Software moderator

The Count(*) will return "0" if there are no records present. You will have to store the value returned by the Count(*) into a variable and cast it into a string. You can use this string in the AddLabel method without any problem.

ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 10:09 PM.