Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
The simplest binding to the List<> is not working (?)
posted

Hello,

I am looking for a quick solution - I came across really strange thing - I cannot bind the List<MyClass> to the WinGrid.
MyClass has only properties of simple types: string, double etc.

In the designer mode, I clicked on DataSource of wingrid, and added new bindingsource - MyClass. Then I was able to modify column captions, hide some columns etc in designer mode.

I also added one unbound column which has got formula:

if(isblank([COL1]),0,[COL2]* [COL3]/ [COL1])  //says that compiled succesfully

But when I run my code:

List<MyClass> list = getlist(); //it has count=1 after that

wingrid.dataSource = list;

wingrid.databind();

I got the exception in the main thread, that "Object reference not set to an instance of an object."

I always binded ultragrid with datatable on the fly and everything was correct. Now, when i want to do that in a nicer way (bind to the list of business objects), it throws errors during the first binding in the runtime.

What can be a problem?