You Tube

Tuesday 18 October 2011

Data binding

DataGrid and DataList (among other controls) iterate over a collection automatically and render some HTML for each item (you specify the layout using templates). The automatic data binding of collections works for the following controls: HtmlSelect, CheckBoxList, DataGrid, DataList, Repeater, DropDownList, ComboBox, ListBox, and RadioButtonList. Each of these controls will automatically bind to the following classes representing collections: Array, ArrayList, HashTable, Queue, SortedList, Stack, StringCollection, DataView, DataTable, DataSet, SqlDataReader, and the OleDbDataReader.
Each of the controls I just listed (including DataGrid and DataList) include a property named DataSource. The DataSource property can be any System.Object, but for the data binding to work over a collection, it has to implement IEnumerable.

No comments:

Post a Comment