FILTEREDBINDINGLIST, SORTEDBINDINGLIST and EDIT level problem

FILTEREDBINDINGLIST, SORTEDBINDINGLIST and EDIT level problem

Old forum URL: forums.lhotka.net/forums/t/4529.aspx


pandelaras posted on Thursday, March 20, 2008

I am having a problem binding a child list to these 2 and then persisting list changes to the database. i run into an edit lvl problem. Is there a proper way to do the binding? I have no problem creating filteredbinglists or sortedbindinglists, but i suspect the problem is when i should bind them to the form. I apply the filter to the bindinglist some clicks away using a button and then rebinding properly

Dim FLTVPELATES As Csla.FilteredBindingList(Of SINALLASOMENOI_EC)

Dim strlist As Csla.SortedBindingList(Of SINALLASOMENOI_EC)

 

Public Sub New(ByVal GEF As GEFYRA1)

InitializeComponent()

mGEFYRA = GEF

BindUI()

End Sub

Private Sub BindUI()

mGEFYRA.BeginEdit()

FLTVPELATES = New Csla.FilteredBindingList(Of SINALLASOMENOI_EC)(mGEFYRA.SINALLASOMENOI, AddressOf SINALLASOMENOI_FILTER.Filter)

strlist = New Csla.SortedBindingList(Of SINALLASOMENOI_EC)(FLTVPELATES )

Me.GEFYRA1BindingSource.DataSource = mGEFYRA

Me.SINALLASOMENOIBindingSource.DataSource = strlist

End Sub

 

Private Sub RebindUI(ByVal saveObject As Boolean, ByVal rebind As Boolean)

Me.GEFYRA1bidingSource.RaiseListChangedEvents = False

Me.SINALLASOMENOIBindingSource.RaiseListChangedEvents = False

Try

UnbindBindingSource(Me.SINALLASOMENOIBindingSource, saveObject, False)

UnbindBindingSource(Me.GEFYRA1bidingSource, saveObject, False)

Me.SINALLASOMENOIBindingSource.DataSource = Me.GEFYRA1bidingSource

' save or cancel changes

If saveObject Then

mGEFYRA.ApplyEdit()

Try

Dim temp As GEFYRA1 = mGEFYRA.Clone()

mGEFYRA = temp.Save()

Catch ex As Csla.DataPortalException

MessageBox.Show(ex.BusinessException.ToString(), _

"Error saving", MessageBoxButtons.OK, _

MessageBoxIcon.Exclamation)

Catch ex As Exception

MessageBox.Show(ex.ToString(), _

"Error Saving", MessageBoxButtons.OK, _

MessageBoxIcon.Exclamation)

End Try

Else

mGEFYRA.CancelEdit()

End If

' rebind UI if requested

If rebind Then

BindUI()

End If

Finally

'// rebind the UI

GEFYRA1bidingSource.DataSource = mGEFYRA

' restore events

GEFYRA1bidingSource.RaiseListChangedEvents = True

Me.SINALLASOMENOIBindingSource.RaiseListChangedEvents = True

If rebind Then

' refresh the UI if rebinding

Me.GEFYRA1bidingSource.ResetBindings(False)

Me.SINALLASOMENOIBindingSource.ResetBindings(False)

End If

End Try

End Sub

Copyright (c) Marimer LLC