Object Reference > True DBGrid Methods > ExportBegin Method |
ExportBegin Method
The ExportBegin method prepares the grid for export to an HTML file by creating an internal clone of the current recordset.
TDBGrid.ExportBegin [bookmark]
Arguments
bookmark is an optional bookmark that specifies the first row to be exported. If omitted, the first available row is used.
Return Value
None
Each call to the ExportBegin method must be matched by a corresponding call to the ExportEnd method.
You must call the ExportBegin method prior to calling the ExportRows method, which outputs an HTML table to a specified file.
These methods are typically used in server-side applications that present ad hoc query data as a series of HTML tables containing a small number of rows. In such applications, you can store the value returned by the ExportNextBookmark property in a database or collection object for the next call to the ExportBegin method, as in the following example:
Private Sub WebItem1_Respond()
' If there are no cookies, start exporting from the beginning of the file,
' otherwise the "user" cookie contains the bookmark of the next row to be
' exported.
If Request.Cookies.Count = 0 Then
TDBGrid1.ExportBegin
Else
TDBGrid1.ExportBegin Request.Cookies("user"))
End If
' Export ten rows, overwriting the file's contents.
TDBGrid1.ExportRows FileName, False, 10
' Store the next bookmark in the "user" cookie.
Response.Cookies("user") = TDBGrid1.ExportNextBookmark
' Terminate the export operation and redirect the browser to the file
' containing the HTML table.
TDBGrid1.ExportEnd
Response.Redirect FileName
End Sub