PRB: Setting a Default Value in a Client Listbox DTC

ID: Q194017


The information in this article applies to:


SYMPTOMS

When you attempt to set a default (selected) value of a Listbox Design-time control (DTC) with the Scripting Platform set to "Client (IE 4.0 DHTML)" and the Row Source set to a Recordset DTC with the Scripting Platform set to "Client (IE 4.0 DHTML)", no default value is set when you use the following code in the Window_onload or Recordset1_ondatasetcomplete events:


   Listbox1.selectedIndex = 0; 
-or-

   Listbox1.selectByText("text"); 


RESOLUTION

To set a default value in the Window_onload event you must use the following code:


  Recordset1.advise(RS_ONDATASETCOMPLETE, "Listbox1.selectedIndex=0"); 
-or-

  Recordset1.advise(RS_ONDATASETCOMPLETE, "Listbox1.selectByText('text')"); 
This defers selection of an item until after the Listbox DTC is initialized by the Recordset DTC.


STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Open a Visual InterDev Web project with a data connection.


  2. Add a new .html page, right-click the page and select properties.


  3. Set your Default Scripting Language for client to JavaScript (ECMAScript), and then select OK.


  4. Add a Recordset DTC.


  5. Add a Listbox DTC and set the Row Source to the Recordset DTC.


  6. Select the Script Outline tab. If this tab is not present, from the View menu, choose Other Windows and then select Script Outline.


  7. Expand "Client Objects & Events", expand "Window" and double-click the Onload event.


  8. A function appears in your editor.


  9. Add the following code to the Onload event:
    
          Listbox1.selectedIndex = 0; 


  10. Right-click in the page and choose "View in Browser". Answer "Yes" to the prompt to save the changes.


RESULT: No default value is set.

Additional query words: kbVisID600 kbDSIASPGrp


Keywords          : kbCtrl kbide kbVisID600 kbGrpASP 
Version           : WINDOWS:6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 27, 1999