Jump to content

Recommended Posts

Posted

Hello,

 

I have a collection called "SupplierCollection" this is a generic binding*list of T. Where T is any class that derrives from SupplierBase. So I have 4 classes that derrive from SupplierBase and i've created 4 instances of SupplierCollection each with 10 items in. So:

 

Dim oTransferSupplierCollection as new SupplierCollection(TransferSupplier)

Dim oAccommodationSupplierCollection as new SupplierCollection(AccommodationSupplier)

Dim oFlightSupplierCollection as new SupplierCollection(FlightSupplier)

Dim oCarSupplierCollection as new SupplierCollection(CarSupplier)

 

I change the binding source (bsSuppliers)*to any of these data sources,*My SupplierCollection has a method SaveCollection(). I want to call the SaveCollection method from the binding source. I'm trying to use this code to do it:

 

Dim oObj AsObject = bsSuppliers.List

Dim oType As Type = oObj.GetTypeDim oMethodInfo As System.Reflection.MethodInfo = oType.GetMethod("SaveCollection")

oMethodInfo.Invoke(oMethodInfo, Nothing)

 

Everytime*I run it I get the error: "Object does not match target type.". This error occurs when I call "oMethodInfo.Invoke(oMethodInfo, Nothing)".

 

I'm sure there is a more pleasant way to this but i've been at this for an hour now and not getting anywhere. Any ideas?

 

More...

 

View All Our Microsoft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...