Data Binding Controls in .NET acquisition

xiaoxiao2021-03-06  41

The application of data binding in .NET is very broad, such as DataGrid, you can bind DataTable, or bind an arraylist, in fact, as long as it inherits the type of interface IENUMERABLE, it can be binded, then When we write the control, we also achieve this binding. In fact, it is very simple, take DataGrid's Datasource, DataGrid.DataSource = DataTable.defaultView; actually in the program, this is so real, first define a variable Private IEnumerable _datasource; then add attribute public ienumerable DataSource;} set {_datasource = value;}} When actual data binding, the program can get DataBinder.getPropertyValue to get the value of the enumeration data source, as follows Implementation: IEnumerator_dataitems = _DataSource.GeteNumerator (); // Get an iterator while (_dataitems.movenext ()) {Output.writln (DataBinder.current, "name"); // Name is the property name, For example, the field name in DataTable or the object name, etc.} is not very simple. In the actual project, it is often an opportunity to have some controls and can perform data binding, and DataBinder from .NET is a function. Very powerful module

转载请注明原文地址:https://www.9cbs.com/read-55849.html

New Post(0)