Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

Sponsored Links

Discuss "No Default Member Found for type" in the .Net Development forum.

.Net Development - Learn about the Microsoft.Net framework and how to create powerful web-based (ASP.net) and client-based (Windows Forms) applications utilizing various languages such as C#, VB.Net, J# and others.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old May 29th, 2008, 12:31 PM
richyrich's Avatar
Moderator


 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 395
Thanks: 26
Thanked 32 Times in 32 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default 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 08:07 AM.
Reply With Quote
Sponsored Links
  #2  
Old May 29th, 2008, 01:09 PM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

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. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
The Following User Says Thank You to Wolffy For This Useful Post:
richyrich (May 29th, 2008)
  #3  
Old May 29th, 2008, 01:16 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 806
Thanks: 19
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft SQL Server Microsoft Windows Microsoft .Net Classic ASP 
Total Awards: 4

Default

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 with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
richyrich (May 29th, 2008)
  #4  
Old May 29th, 2008, 01:21 PM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Shoot - I didn't even read the last code block -- that's what I get for doing lunch as the same time as posting.
Reply With Quote
  #5  
Old May 29th, 2008, 01:27 PM
richyrich's Avatar
Moderator


 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 395
Thanks: 26
Thanked 32 Times in 32 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

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

Thanks Wolffy for your reply... I could do with something to eat myself!!
Reply With Quote
  #6  
Old May 29th, 2008, 01:33 PM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

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?
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webform Default Button Devwhiz .Net Development 9 May 15th, 2008 01:15 PM
Computer \\COMPUTERNAME cannot be managed. The network path was not found. jmurrayhead Microsoft Windows 0 April 25th, 2008 06:43 PM


All times are GMT -4. The time now is 07:57 AM.



Content Relevant URLs by vBSEO 3.2.0