次の方法で共有


How to: Display Bound Data in a DataRepeater Control (Visual Studio)

The most common use of the DataRepeater control is to display bound data from a database or other data source.

In addition to bound controls, you may want to add other controls, such as a static label or an image that is repeated on each item in the DataRepeater control. For more information, see How to: Display Unbound Controls in a DataRepeater Control (Visual Studio).

You can also bind to a data source at run time by setting the VirtualMode property to True and assigning a data source to the DataSource property. In this case, you will need to manage all interaction with the data source. For more information, see Virtual Mode in the DataRepeater Control (Visual Studio).

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings.

To create a data-bound DataRepeater

  1. Drag a DataRepeater control from the Visual Basic PowerPacks tab in the Toolbox to a form or container control.

  2. Drag the sizing and position handles to size and position the control.

    Note that the control has two rectangular regions. The upper region is the item template; controls added to the template will be repeated in each item in the DataRepeater control at run time. The lower region is the viewport, where the items will be displayed.

    You can also size and position the control or the item template by changing the Size and Position properties in the Properties window.

  3. On the Data menu, click Show Data Sources.

    Note

    If the Data Sources window is empty, add a data source to it. For more information, see Data Sources Overview.

  4. In the Data Sources window, select the top-level node for the table that contains the data that you want to bind.

  5. Change the drop type of the table to Details by clicking Details in the drop-down list on the table node.

  6. Select the table node and drag it onto the item template region of the DataRepeater control.

    You can specify which types of controls are displayed for each field. For more information, see How to: Set the Control to be Created when Dragging from the Data Sources Window.

See Also

Tasks

How to: Display Unbound Controls in a DataRepeater Control (Visual Studio)

How to: Create a Master/Detail Form by Using Two DataRepeater Controls (Visual Studio)

How to: Change the Appearance of a DataRepeater Control (Visual Studio)

Troubleshooting the DataRepeater Control (Visual Studio)

Reference

DataRepeater

Concepts

Introduction to the DataRepeater Control (Visual Studio)