NotSupportedException ?

NotSupportedException ?

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


AKaplan posted on Saturday, December 12, 2009

I get an error when using the NameValueListBase object at the DataPortal_Fetch method.

_
Protected Overloads Sub DataPortal_Fetch()
RaiseListChangedEvents = False
Using ctx = ContextManager(Of T).GetManager(T)
For Each p In ctx.DataContext.ProductCategories
Add(New NameValuePair(p.ID, p.Name))
Next
End Using
RaiseListChangedEvents = True
End Sub

It throws an exception in the ReadOnlyBindingList at

Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As C)
If (Not IsReadOnly) Then
InsertIndexItem(item)
MyBase.InsertItem(index, item)
Else
Throw New NotSupportedException("")
End If
End Sub

Can someone give me an idea of whats going on?

triplea replied on Saturday, December 12, 2009

You need to set IsReadOnly = false in your Fetch method just after setting RaiseListChangedEvents to False. Do not forget to reset it back to True once you ar efinished loading your list.

Copyright (c) Marimer LLC