Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Using Data Binding with ASP.NET Mobile Controls 

ASP.NET mobile controls enable Web applications to easily interface with databases. This technique is called data binding. Data binding takes advantage of the power of Microsoft ADO.NET DataSet and DataTable objects. These objects enable mobile Web pages to connect to databases.

A DataSet object represents a set of data that includes data tables as well as the relationships between them. Controls on the page can bind to a specific field in a DataTable object, which is how ASP.NET mobile controls enable users to display and manipulate data.

The mobile Web page framework provides a flexible means of binding controls to information in a data store. To perform data binding programmatically, applications invoke the DataBind method of a control that is bound to the data. You can also configure data binding at design time in Visual Studio.

Mobile Web pages enable applications to perform both simple and complex data binding. Simple data binding enables applications to bind a control property to a single value in a database. Complex data binding involves connecting a control to a set of values, such as a column in a DataTable object. For instance, applications often use data binding to populate List controls with items that the user can select.

NoteNote

Unlike ASP.NET Web controls, data binding for mobile Web pages does not use data source controls such as the SqlDataSource control and the corresponding DataSourceID property in bound controls. Instead, you set the DataSource property of a control either declaratively or in code, and then call the DataBind method.

For more information, see the links listed in the following table.

Link source Description

Creating a DataTable

Describes binding to a DataTable object, which represents one table of in-memory data. DataTable objects can be created and used independently, or can be used by other Microsoft .NET Framework objects, most commonly as a member of a DataSet object.

DataBind

Performs binding between a server control property and a data source.

List

Renders a list of items as either a static display or an interactive list. For more information, see the DataTextField and DataValueField topics.

ObjectList

Renders multiple data fields for each item in the object list.

Using DataSets in ADO.NET

Describes creating DataSet objects, relations, and constraints, and populating them with data.

Tables Collection Editor

Enables you to add and remove DataTable objects to or from a dataset. This dialog box appears when you are using the Properties window to edit the Tables property of a dataset.

Accessing Data with a Data Adapter

Before an application can access data in a database, it needs to create a connection to the database and to configure a data adapter. For information about common data adapter properties, see DataAdapter. For details about adding data sources and adapters to your project, see Data Adapter Configuration Wizard.

Data Binding Properties

The following table lists commonly user properties of data-bound controls:

DataSource

Specifies the data source for the data to populate the list. This can specify the name of a dataset or a data table.

DataMember

Specifies the name of the table to use from the DataSource property that you selected.

DataTextField

Specifies the name of a field (for example, a column in the table) to associate with the Text property for each item in the control.

DataValueField

Specifies the name of a field to associate with the Value property for each item in the control. A typical use is to specify the primary field of a data record so that at run time you can identify the data row displayed in the list.

In addition, the ObjectList control supports the properties listed in the following table:

LabelField

Specifies the Name value or DataField value of the field to be used as a label for the item.

TableFields

Specifies which fields are shown in the list view.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.