![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| 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
Code: <asp:repeater ID="dlst_comm" runat="server" OnItemDataBound="dlst_comm_onitemdatabound"> 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
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
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
Thanks Last edited by richyrich; July 9th, 2008 at 08:07 AM. |
| Sponsored Links |
|
#2
| ||||
| ||||
| 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. |
| The Following User Says Thank You to Wolffy For This Useful Post: | ||
richyrich (May 29th, 2008) | ||
|
#3
| ||||
| ||||
| 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 |
| The Following User Says Thank You to jmurrayhead For This Useful Post: | ||
richyrich (May 29th, 2008) | ||
|
#4
| ||||
| ||||
| Shoot - I didn't even read the last code block -- that's what I get for doing lunch as the same time as posting. |
|
#6
| ||||
| ||||
| 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? |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |