CSLA .NET

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

Strange behaviour of datagridview binded to sortedbindinglist

rated by 0 users
Not Answered This post has 0 verified answers | 2 Replies | 1 Follower

Not Ranked
7 Posts
Marius posted on Tue, Apr 19 2011 9:07 AM

I encountered strange behavior of datagridview:

 

In the parent object  (invoice) I have a childlist (invoiceitemlist) that I expose through a property like this:

Public ReadOnly Property InvoiceItemList() As Csla.SortedBindingList(Of InvoiceItem)
   Get
         Return _InvoiceItemList.GetSortedList
   End Get
End Property

Adequate method in childlist is:


<NonSerialized()> _
Private _SortedList As Csla.SortedBindingList(Of InvoiceItem) = Nothing

Public Function GetSortedList() As Csla.SortedBindingList(Of InvoiceItem)
     If _SortedList Is Nothing Then _SortedList = New Csla.SortedBindingList(Of InvoiceItem)(Me)
     Return _SortedList
End Function

 

Binding is implemented by VS GUI (draging form datasources).

 

I also have the same implementation (with private field) of exposing SBL in parentrootlist.

 

But in the first case databinding cancelnew method  wouldn't work and in the second case it works perfectly. What could be a reason for that?

All Replies

Top 10 Contributor
3,922 Posts
Andy replied on Wed, Apr 20 2011 6:28 PM

Don't expose the SBL as a property from your BO.  Instead, wrap the property in a SBL before you bind it to the BindingSource.  You'll have to write a bit of code to do this, but it should resolve your issue.

Not Ranked
7 Posts
Marius replied on Thu, Apr 21 2011 3:50 AM

I implemented printing of BO by passing the object to the printing method. In order to support transfer of the sorting state (also filtering in some cases) of the object to the printing method the object itself should contain a reference to the actual sorted/filtered list. So wrapping the object on GUI side is not an option.

Besides I can't quite understand why can't  I do it inside a property? What's the difference when doing the same thing on GUI side or BO side?

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