



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Specify the data in the control’s properties Not dynamic: can’t get data from a database
Write code that uses the control’s object model This is okay if you need to populate a simple value or list, but quickly gets too complicated for populating sophisticated displays
Data binding Create an object that holds the data (DataSet, Array, string, int, etc.) Associate that object with the control
Provides a single simple yet powerful way to populate Web controls with data Enables clean separation of code from UI Supports binding to any data source Properties, expressions, method calls Collections (Array, Hashtable, etc.) DataSet, DataTable, DataView, DataReader XML
Dragging/dropping tables from Data Sources Window onto form will create instances of: DataSet, TableAdapter, BindingSource BindingNavigator with nav/add/delete/save controls Bound control(s) Use Data Sources window to configure: Whether table will be edited with DataGridView or “Details” mode (individual controls) Mapping of detail control types to column data types (shortcut to Windows Forms Designer/Data UI Customization node in Options dialog)
As before Consist of DataTables, Relations, Constraints Drag/drop from Server Explorer is supported Based on XML schema and code-behind class Also consists of TableAdapters Encapsulate a DataAdapter and a Connection Enhanced Typed Dataset Designer Instead of XSD Designer earlier Partial class support
Have Queries (methods for handling selects, updates, inserts, deletes)
Queries exists as methods
Fully customizable and extendable
Can be re-used across multiple forms
Have Connection property Connection string typically stored in web/app.config; default value applied in WinForms apps.
Acts as “broker” between bound controls and actual data source DataSource, DataMember Point to typed DataSet, DataTable
AllowEdit, AllowNew, AllowRemove Filter, Sort properties Run time: RemoveFilter, RemoveSort methods
MovePrevious, MoveNext, MoveFirst, MoveLast, Position, Count properties (handles all navigation)
AddNew, Insert(index, obj) methods
RemoveCurrent , RemoveAt(index), Remove(obj)
EndEdit, CancelEdit methods Works with edits and inserts/new’s
Use of most of these is optional due to…
Complex and Simple Binding Scenarios
Complex Binding DataGridView.DataSource = BindingSource
SimpleBinding TextBox.Text (and other controls/string-based properties) bound to member of BindingSource BindingNavigator.BindingSource = BindingSource