HOWTO: Using the bindAllColumns Method to Rebind a Grid DTCID: Q193226
|
The bindAllColumns method is used to bind all the columns in the current recordset to a Grid Design-time control (DTC). This method is specifically useful when the number of columns in the underlying recordset of a bound Grid DTC changes or is not known at design time. In that case, the bindAllColumns method associated with the Grid DTC has to be called to rebind the Grid with the recordset so that the updated number of columns in the recordset can appear on the Grid.
This example shows a Grid DTC bound to a recordset that is set to the
Customers table in the sample AdvWorks.mdb database. If a different
database is used, modify the select statement in the sample code provided
below to use a valid table from the database.
When the user clicks Button1, the ChangeRS function is called in the
onclick event of Button1. The recordset is closed and the setSQLText of
the recordset is changed. Then the Grid DTC is rebound to the new recordset
using the bindAllColumns method.
Following are the step-by-step procedures:
<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub Button1_onclick()
call ChangeRS
End Sub
Sub Grid_onenter()
If thisPage.firstEntered then
Recordset1.open
End if
End Sub
Sub ChangeRS()
If Recordset1.isOpen() then Recordset1.close()
'Change to a New SQL Statement
Recordset1.setSQLText( "Select * from Employees")
Recordset1.open
Grid1.bindAllColumns
End Sub
</SCRIPT>
Additional query words:
Keywords : kbCtrl kbVisID600 kbGrpASP
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 27, 1999