PRB: Visual InterDev 6.0 Grid DTC User Interface Is Not Visible After a Roundtrip to the Server (232324)



The information in this article applies to:

  • Microsoft Visual InterDev 6.0

This article was previously published under Q232324

SYMPTOMS

In certain scenarios, you may find that your Grid Design-Time Control (DTC) user interface (UI) is not visually rendered when you click the Recordset Navigation button or the Page Navigation button. This happens most frequently when you call parameterized queries or stored procedures and use the Grid DTC to display the results. The Grid DTC user interface may not be displayed after a roundtrip to the server.

CAUSE

This behavior is due to a state preservation problem of the Grid DTC Script object. The _DG_Display() function in the DataGrid.asp page from the _ScriptLibrary folder is used to display the user interface of the Grid DTC on the page. After the Active Server Pages (ASP) page makes a roundtrip to the server, the Recordset DTC, which the Grid DTC is bound to, may be lost. In these cases, the objRS._isEmpty() function returns true when it is called by the _DG_Display() function. As a result, the grid is not displayed on the page.

RESOLUTION

To work around this problem, add the following code to manually reopen the Recordset DTC in the Button1_onClick() event handler:
Sub Button1_onclick()
 If Recordset1.isOpen() then
	Recordset1.close
 end if
 Recordset1.setParameter 0,Textbox1.value
 Recordset1.open
End Sub
				
NOTE: If you are passing a value automatically to the Recordset DTC, for example when you specify Textbox1.value in the Value field of the Parameters tab of the Recordset DTC, you must remove that entry from the Value field. You do not want to use a DTC value as the default parameter in a Recordset DTC. When the next page arrow is clicked, the page is redrawn, and that value is temporarily lost. Therefore, an empty parameter is sent to the Recordset DTC.

MORE INFORMATION

Steps to Reproduce Behavior

Use the following steps to build a sample to call a parameterized query against the SQL Server "pubs" database and demonstrate how the Grid DTC can disappear unexpectedly.
  1. Add a Data Connection to a project that connects to the SQL Server pubs database.
  2. Add a new ASP page to the project.
  3. Drag a Recordset DTC onto the page.
  4. Use the following SQL statement for the Recordset DTC:
    SELECT * FROM authors WHERE State = ?
    					
  5. On the Parameters tab of the Recordset DTC, specify Textbox1.value in the Value field. Keep in mind that the parameter entry is case sensitive.
  6. On the Implementation tab of the Recordset DTC, clear the Automatically open the Recordset check box.
  7. Drag a Textbox DTC, a Button DTC, and a Grid DTC onto the page below the Recordset DTC.
  8. Bind the Grid DTC to Recordset1, and display the au_lname field.
  9. On the Navigation tab, select the Enable paging check box, and then type 2 in the records/page text box.
  10. Add the following code to the Button1_OnClick() event handler:
    Sub Button1_OnClick() 
       If Recordset1.isOpen() Then
          Recordset1.close
       End If
       Recordset1.open
    End Sub
    					
  11. In your browser, open the page. Type CA in the textbox, and click Button1. You should see that the Grid DTC is now populated with data.
  12. Click one of the navigation buttons. The Grid DTC is no longer visible.

Modification Type:MajorLast Reviewed:4/22/2001
Keywords:kbCtrl kbprb KB232324