Visual InterDev

Displaying Data on Your Web Page

See Also

Displaying data is easy using Microsoft® Visual InterDev™. You can connect to a database, specify the set of records to display, and display the records by using data-bound design-time controls, or you can display data directly using script. You can also display data in a grid, showing multiple records from a recordset.

Note   If you are writing ASP pages, you can set options that help you find errors and trace events in the scripting object model. For details, see Debugging Script Objects in ASP Pages.

To display data using a data-bound control

  1. Create a data environment Command object that specifies a set of records from a database. For details, see Getting Records.

  2. Open an ASP or HTML page in the editor.

  3. Drag the Command object from the DataEnvironment folder to the page. This creates a Recordset control on the page.

  4. Drag one or more fields from the Command object to the page.

    The fields are displayed under the Command object in the DataEnvironment folder.

    Each dragged field creates a data-bound control that will display the data from that field in the recordset. Text and numeric fields create Textbox controls. Yes/No or True/False (Boolean) fields create Checkbox controls. For more information, see The Data Environment.

You can easily provide navigation (moving from record to record) among the records you display on your Web page with the RecordsetNavbar control.

To provide navigation among records

  1. Open the ASP or HTML page in the editor.

  2. Drag the RecordsetNavbar control from the Toolbox onto the page.

    Tip   If the RecordsetNavbar control is not shown in the Toolbox, right-click on the Toolbox, choose Customize Toolbox, and add the RecordsetNavbar control.

    The control is inserted onto your ASP or HTML page.

  3. Right-click the control and click Properties to open its property pages.

  4. Set the Recordset property of the control to the name of a Recordset control whose records are displayed on the page.

By default, the RecordsetNavbar control provides Move to First, Next, Previous, and Move to Last buttons. You can use these buttons to move among the records displayed on the page. You can also customize the functionality of these buttons by modifying the script that they create. For more information, see RecordsetNavbar Control.

Navigating Using Script

You can move between records in the recordset by calling navigation methods in the recordset script object. When you move, the record you move to becomes the current record.

Important   When you navigate to another record, the current record is not automatically saved. Be sure that you have copied data to the current record and saved the record before you call a navigation method. For details, see Updating Records.

To navigate using script

If you want to perform a procedure based on navigation, you can write handlers for the onrowenter and onrowexit events. For example, perhaps your application does not simply display only the contents of fields. Instead, you want to use a single text box to display a combination of first and last names.

To do this, you can write a handler for the onrowenter handler that gets values from the recordset, concatenates them, and puts them in a text box. The handler might look like this:

Function rsEmployeeList_onrowenter()
   firstName = rsEmployeeList.fields.getValue("lastName")
   lastName = rsEmployeeList.fields.getValue("firstName")
   txtFullName.value = lastName & ", " & firstName
End function

You can also create a data grid on your Web page using the Grid design-time control. For information on creating a Grid control, see Data-bound Grid Sample and Grid Properties Dialog Box.