BindingCompleted Event

Occurs after data is successfully loaded into or exported from a map through a Refresh or Update method.

Private Sub Spreadsheet_BindingCompleted(BindingId, Action)

BindingId   Required String. The unique ID of an XmlDataBinding object. You can also manually assign a *BindingId   * value by adding the relevant XML fragment that contains data-binding details into an XML Spreadsheet file.

Action   Refers to the type of binding operation that was completed. The possible values are "Refresh" and "Update".

Remarks

A unique BindingId is automatically generated by the Spreadsheet component when you bind to a data retrieval service connection (.uxdc) file. Microsoft Excel also automatically generates a BindingId when you use Excel to create a data-bound spreadsheet and later save it as an XML spreadsheet file. In the XML Spreadsheet file, the XML fragment that contains the BindingId looks something like the following:

<x2:Binding x2:ID="bind_id0" x2:Async="True" 
 xmlns:x2="urn:schemas-microsoft-com:office:excel2"
 xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp"
 xmlns:udc="http://schemas.microsoft.com/data/udc"
 xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:udcs="http://schemas.microsoft.com/data/udc/soap">
   <x2:MapID>map_id0</x2:MapID>
   <udc:DataSource MajorVersion="1" MinorVersion="0">
     <udc:Name/>
     <udc:Type Type="SOAP" MajorVersion="1" MinorVersion="0">
    <udc:SubType Type="DSP" MajorVersion="1" MinorVersion="0"/>
     </udc:Type>
    <udc:ConnectionInfo Purpose="Query">
      <udcs:SOAPAction>http://schemas.microsoft.com/sharepoint/dsp/queryRequest</udcs:SOAPAction>
      <udcs:Location href="Data_Retrieval_Services_URL">SQLDataAdapter</udcs:Location>
      <soap-env:Body>
       <dsp:queryRequest>
        <dsp:dsQuery select="/database[@id='Database_Name']/table[@id='Table_Name']" resultContent="dataOnly">
         <dsp:Query RowLimit="10" QueryType="DSPQ">
          <dsp:Fields>
                     <dsp:Field Name="Column_Name"/>
          </dsp:Fields>          
         </dsp:Query>
        </dsp:dsQuery>
       </dsp:queryRequest>
      </soap-env:Body>
      <soap-env:Header>
       <dsp:versions>
        <dsp:version>1.0</dsp:version>
       </dsp:versions>
       <dsp:dataRoot>
        <dsp:root>SQL_Server</dsp:root>
       </dsp:dataRoot>
       <dsp:request service="DspSql" document="content" method="query"/>
        <dsp:authentication>
        <dsp:basic>
         <dsp:useExplicit>
          <dsp:userId>user_name</dsp:userId>
          <dsp:password>password</dsp:password>
         </dsp:useExplicit>
        </dsp:basic>
       </dsp:authentication>
      </soap-env:Header>
     </udc:ConnectionInfo>
    </udc:DataSource>
</x2:Binding>

The BindingCompleted event is triggered after data is successfully loaded into or exported out of a map through a Refresh or Update method. This event is also triggered when the page is first rendered for query bindings where the LoadMode attribute of the Binding element is set to "normal".

During an asynchronous binding, some methods related to data binding will generate run-time errors saying that the requested operation cannot be completed because an asynchronous binding is in progress. Calls to these methods succeed when the asynchronous binding is done. For more information, see the XMLDataBinding object documentation.

Solution developers should trap the BindingCompleted and BindingError events to find out when the binding is finished. Note that using the BindingCompleted event to select an XML row does not send that row to a part-to-part binding consumer when the page is loaded. Use the Window.Onload event for that purpose.

The following XML fragment example shows LoadMode = "normal":

<x2:Binding x2:ID="Bind_id89929" x2:LoadMode="normal" x2:Async="true" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml">
    ...
</x2:Binding>

The following example shows how to trap the BindingCompleted event from script running in a Web page when the page is first loaded and whenever the user refreshes the bound data (the behavior when the LoadMode attribute is set to "normal"). To work correctly, you must put the event handler for the BindingCompleted event in a <SCRIPT> tag that is located before the <OBJECT> tag of the Spreadsheet component.

<SCRIPT language=vbscript for="Spreadsheet1" event="BindingCompleted(bindingID, Action)">

    If Spreadsheet1.ActiveWorkbook.XmlDataBindings.Item(bindingID).CanQuery = True Then

        MsgBox "Binding Completed."

    End If

</SCRIPT>

<OBJECT id=Spreadsheet1 classid=CLSID:0002E559-0000-0000-C000-000000000046>
    ...
</OBJECT>

Applies to | Spreadsheet Object