Data Binding: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
m New page: Data Binding with C# '''Binding''' is used to create a two-way connection between a data object and a Windows control. '''One-way''' means that the data can be displayed in the control. ...
 
Brian Wilson (talk | contribs)
mNo edit summary
 
Line 25: Line 25:


So... for a "simple" example,
So... for a "simple" example,
* You create a DataTable
* You create a DataSet
* You create a DataSet and add the DataTable to it
* You create a DataAdapter and specify the table you want to use with a bit of SQL
* You create a DataAdapter and specify the table you want to use with a bit of SQL
* You connect the actual table to the DataTable by connecting the DataAdapter to the DataSet
* A DataTable to contain the table will be added to the DataSet
* If you connect the DataTable to a control via its DataSource property, you can see the table contents.
* If you connect the DataTable to a control via its DataSource property, you can see the table contents.

Latest revision as of 01:38, 3 February 2008

Data Binding with C#

Binding is used to create a two-way connection between a data object and a Windows control.

One-way means that the data can be displayed in the control. Example: a list of elements living in a SQL table can be used to populate a list control.

Two-way means that the control can be used to update the data. Example: a SQL table can populate a DataGridView table and when a cell in the table is changed the SQL table can be updated.

DataSet a DataTable collection, with relations and constraints. Relations can be created with DataRelation objects.

DataTablea data container that represents a table; it contains DataRow and DataColumn collections.

DataView a DataTable container with some additional properties available including Filter and Sort.

DataAdapter is a container for the SQL commands and database connection that us used to fill a DataSet.

So... for a "simple" example,

  • You create a DataSet
  • You create a DataAdapter and specify the table you want to use with a bit of SQL
  • A DataTable to contain the table will be added to the DataSet
  • If you connect the DataTable to a control via its DataSource property, you can see the table contents.