CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Problem Binding a BusinessListBase to DataGridView on WinForms

rated by 0 users
Answered (Verified) This post has 1 verified answer | 2 Replies | 0 Followers

Not Ranked
9 Posts
foxhard posted on Wed, Jul 4 2012 3:00 PM

Hi,

I need some help with EditableRootListBase class binding issue. I have EmployeeAccountList binded to  DataGridView used on a Windows Forms. Then When I change some data and try save then I get an exception: {"Edit level mismatch in AcceptChanges"}

I guess the problem is with the binding, because when I try the same using DevExpress GridControl, then nothing appear and the save is successfully.

I have written a test for try it, you can download from here:  http://ge.tt/7w8GW2K/v/0?c

The solution is in VS2010. written in C# and it use CSLA 3.8.4.

The CSLA.dll is include in the folder.

Regards,

Answered (Verified) Verified Answer

Top 10 Contributor
1,813 Posts

Hi,

You must understand the concept of Bind and Unbind business object and UI.

IE: You cannot call Save on an object that is databound and sequence of Bind/Unbind is also important to get right. 

I strongly suggest that you look at the BindingSourceExtensions in CslaContrib:
http://cslacontrib.codeplex.com/SourceControl/changeset/view/98444#1623433

IE: Unbind befor call to Save and then rebind before you can show a message dialog (as the DataGridView cannot get its items to show in the UI).

My blog post here about the sequence: http://jonnybekkum.wordpress.com/2009/10/20/forms-databinding-the-magic-sequence-of-binduiunbindui/

I also recommend these documents for Windows Forms:
DataBindingFAQ
DataGridViewFAQ

See attached zip file for updated solution.

Jonny Bekkum, Norway CslaContrib Coordinator

All Replies

Top 10 Contributor
1,813 Posts

Hi,

You must understand the concept of Bind and Unbind business object and UI.

IE: You cannot call Save on an object that is databound and sequence of Bind/Unbind is also important to get right. 

I strongly suggest that you look at the BindingSourceExtensions in CslaContrib:
http://cslacontrib.codeplex.com/SourceControl/changeset/view/98444#1623433

IE: Unbind befor call to Save and then rebind before you can show a message dialog (as the DataGridView cannot get its items to show in the UI).

My blog post here about the sequence: http://jonnybekkum.wordpress.com/2009/10/20/forms-databinding-the-magic-sequence-of-binduiunbindui/

I also recommend these documents for Windows Forms:
DataBindingFAQ
DataGridViewFAQ

See attached zip file for updated solution.

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
9 Posts

Thanks Jonny, now it looks great.

Page 1 of 1 (3 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems