Results 1 to 3 of 3

Thread: DataBind Formview to function with progrmatic type

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    Manchester, England, UK
    Posts
    247

    DataBind Formview to function with progrmatic type

    I'm trying to databind a formview to the following two functions.
    Is there an easy way to do this?
    ODS doesnt like the "of configtype as new"


    Public Shared Function GetConfig(Of configtype As New)() As configtype

    End Function

    Public Shared Function SetConfig(ByVal configItem As Object) As Boolean

    End Function

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: DataBind Formview to function with progrmatic type

    Granted, my VB.Net is as up to date as my C#, but to me, that Function definition doesn't look right to me at all.

    Can you clarify what you are trying to do in the parameter list? You haven't specified whether the parameter is ByVal or ByRef.

    What am I missing?

    Gary

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    Manchester, England, UK
    Posts
    247

    Re: DataBind Formview to function with progrmatic type

    Sorry, I should have specified this is VB, but I figured you worked that out....

    This particular function requires you to pass in an object which defines the return type so you can get an explicit type.

    The challenge I'm having is that the object data source doesn't seem to handle the config type GetConfig(Of configtype As New)()

    "Of configtype as New" means that the object must have a constructor , so a simplistic example would be :

    Public Shared Function GetConfig(Of configtype As New)() As configtype
    Dim myObj As New configtype
    return myObj
    End function

    this will return an object of type configType

    config type is just a custom class.

    Edit** to give you another example

    Public Shared Function GetConfig(Of configtype As New)(ID as integer) As configtype

    this shows a traditional parameter as well which you might be more familiar with.
    Last edited by DanInManchester; Aug 5th, 2011 at 04:32 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width