views:

22

answers:

1

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)?

A: 

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.

Dave Swersky
I will have only one row in each datastore. But there will be arround 100 datastores.
FrenkR
I did use DataTable with 1 row. Of course I Would like to have more lightweight component but usin datatable is the easiest way to do right now.
FrenkR