+ Reply to Thread
Results 1 to 6 of 6

Thread: No Default Member Found for type

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    No Default Member Found for type

    I'm using a class to create a list of items to show in a repeater. I'm getting an error saying "No default member found for type <Type>" when I try to use a DataItem in OnItemDataBound event.
    BOL
    Code:
        Public Class PolicyCommList
            Inherits List(Of PolicyCommissionBOL)
            Public Sub New()
            End Sub
            Private _page_error As String = String.Empty
            Public Property page_error() As String
                Get
                    Return _page_error
                End Get
                Set(ByVal value As String)
                    _page_error = value
                End Set
            End Property
        End Class
     
        Public Class PolicyCommissionBOL
     
            Private _introducer As String = String.Empty
            Public Property introducer() As String
                Get
                    Return _introducer
                End Get
                Set(ByVal value As String)
                    _introducer = value
                End Set
            End Property
     
         End Class
    
    My Repeater:-
    Code:
    <asp:repeater ID="dlst_comm" runat="server" OnItemDataBound="dlst_comm_onitemdatabound">
    
    Binding the repeater
    Code:
                Dim commlist As PolicyCommList = CommBLL.GetCommList(PolicyDetails.policyref)
                If Not IsNothing(commlist) Then
                    dlst_comm.DataSource = commlist
                    dlst_comm.DataBind()
                Else
                    lbl_nocomm.Visible = True
                End If
    
    OnItemDataBound
    Code:
        Protected Sub dlst_comm_onitemdatabound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                Dim img_intro As Image = e.Item.FindControl("img_introducer")
                If Not String.IsNullOrEmpty(e.Item.DataItem("introducer")) Then img_intro.Visible = True
            End If
        End Sub
    
    When I load the page I get this error:-
    System.MissingMemberException: No default member found for type 'PolicyCommissionBOL'.
    on line:-
    Code:
                If Not String.IsNullOrEmpty(e.Item.DataItem("introducer")) Then img_intro.Visible = True
    
    I can't see why there wouldn't be a value for introducer. Any ideas how I can fix this error?

    Thanks
    Last edited by richyrich; July 9th, 2008 at 09:07 AM.

  2. #2
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    RR
    From what I've found, the error seem to be unique to VB.NET and occurs during late binding events -- like databinding in a Repeater. I'm thinking the problem is in you ItemTemplate control and that the Repeater has no idea what property to bind to. Take a look at this MSDN article for info on this error; http://msdn.microsoft.com/en-us/library/zzh9ha57(VS.80).aspx.

    Also, if you could post your ItemTempate code, we should get this sorted.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #3
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Code:
    Protected Sub dlst_comm_onitemdatabound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            Dim img_intro As Image = e.Item.FindControl("img_introducer")
            Dim myIntroducer As PolicyCommissionBOL = e.Item.DataItem
            If Not String.IsNullOrEmpty(myIntroducer.introducer) Then
                img_intro.Visible = True
            End If
        End If
    End Sub
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  4. #4
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Shoot - I didn't even read the last code block -- that's what I get for doing lunch as the same time as posting.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  5. #5
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Thanks J....Worked like a charm...

    Thanks Wolffy for your reply... I could do with something to eat myself!!

  6. #6
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Yeah, what I shoulda realized is that your original code was trying to index your object like you would a datatable. Since there was no specific method for handing the index, it was looking for the default property.

    I least I think that's right -- I don't know -- unsure of my name -- where am I?
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

+ Reply to Thread

Similar Threads

  1. Webform Default Button
    By Devwhiz in forum .NET Development
    Replies: 9
    Last Post: May 15th, 2008, 02:15 PM
  2. Replies: 0
    Last Post: April 25th, 2008, 07:43 PM

Bookmarks

Posting Permissions

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

SEO by vBSEO