How to: Generate Summary and Edit Views for Data Applications (Devices)

Use data forms to view and edit single rows of data in a datagrid.

The data form user interface consists of two dialog boxes. The View dialog box displays a summary view of a selected datagrid row, and the Edit dialog box enables editing of the row.

  • You open the View dialog box in a running application by double-clicking a row in the datagrid on the Device Emulator or by tapping a row on a device.

  • You open the Edit dialog box by clicking (tapping) New when the datagrid is displayed. This action creates a new row in the datagrid. Alternatively, click (tap) Edit when the View dialog box is displayed.

Data forms are designed as templates for customization. You should add appropriate code for validating and committing changes to the database as part of this customization.

The changes that were made by using the data forms are not persisted in the database. For more information about how to persist those changes, see How to: Persist Data Changes to the Database (Devices).


This feature is supported only for data sources created against SQL Server Compact 3.5 and Server Database Datasets. It is not supported for Result Sets, Business Objects, or Web services.

The following steps assume that you have a SQL Server Compact 3.5 database available in the Data Sources window. For more information, see How to: Create a Database (Devices). This topic also describes how to add an existing SQL Server database as a data source to your project.


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 Visual Studio Settings.

To generate the data forms

  1. Drag a table in Datagrid format from the Data Sources window onto the form in the designer.

    You can select the format by clicking the arrow at the right of the table name.

  2. Click the smart tag on the dragged component, and click select Generate Data Forms.

    The keyboard shortcut to open the Tasks dialog box is Shift+Alt+F10.


    The dialog boxes are briefly displayed as they are generated in the designer. To verify that the dialog boxes are now part of the project, look for them in Solution Explorer.

To modify data in a running application

  1. Start the data application.

    The datagrid is displayed and populated with data.

  2. Double-click a row of data.

    A summary view of that row appears in the View dialog box. This view consists of a label and data for each column that has contents. That is, the View dialog box hides all columns whose values are DBNULL.

  3. On the main menu, click Edit to open the Edit dialog box.

    Use the Edit dialog box, which displays all columns, to modify the data, and then click OK.

    The revised data is displayed in the datagrid.

To create a new row in the datagrid in a running application

  1. With a datagrid open, on the main menu, click New.

    The Edit dialog box appears. Use this dialog box to add a new row of data.

  2. Click OK.

    The new row is added to the datagrid.

See Also


Using SQL Server Compact 3.5 Databases (Devices)