简体   繁体   中英

DataTable type of array binding in cf.net

I would like to make a (very lightweight) 2-way binding datastore. Values must be accessed via names . I was thinking of using 2 arrays:

public class MyBindingDatastore{
    public string[] _names = new string[]{"Field1", "Field2", "Field3"}
    public object[] _values = new object[]{ DateTime.Now, "MyValue", 1}
}

First array is used to store field names(always 1 row). Second array( can be also 2D if more than 1 record) represent value matrix. Using GUI widget(Resco detailview or any that support 2-way databinding), I would like to specify:

MyControl.DataMember = "Field1";
MyControl.DataSource = new MyBindingDatastore();

Result of databinding should be properly displayed value from the value array. After a value inside GUI widget is changed, a change must occour in a datastore(value array) too.

Any idea on how to implement that? Or, is it better to use more bloated DataTable class to mimic datatable binding (I believe that DataTable has a lot overhead against array)?

If you're wanting to use DataBinding you should probably stick with the DataTable. Otherwise you will have to implement your own databinding anyway. If memory size is your concern, look for ways to minimize the amount of data loaded to memory at one time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM