views:

208

answers:

1

Everyone raves about BindingList in place of DataTable.

How do you guys overcome the problem of column flexibility? For BindingList I need to define and implement T object. If any new columns needed to be added, I need to add new properties to T object....while in DataTable this is much easier.

BindingList<T> samples = new BindingList<T>();

Is that something you live with or is there a relatively easy way to overcome thing?

using c# 2.0, compact framework.

+1  A: 

There are still (occasional) advantages to using DataTable - and having column flexibility is one of them. That being said, there are cons as well.

A small comparison of advantages and disadvantages to each are listed in this blog post.

My personal rule of thumb is to use BindingList<T> to bind to a collection of business objects. In this case, the column issue goes away (you know the columns that are useful in advance already), and it feels much more natural.

DataTable is still useful if you're binding to an unknown thing, and trying to do the parsing at runtime.

Reed Copsey
Thanks. My scenario is that I know ahead of the time what it is I am going to parse. But the business objects would be pretty complex to convey that should I decide to go with the BindingList<T>. But on the other hand, I can see a lot of advantages down the road. here is my question that describes my scenariohttp://stackoverflow.com/questions/1173359/from-datatable-to-bindinglist/1173942#1173942
gnomixa