Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gridview and subobjects

Status
Not open for further replies.

JudyBarer

Programmer
Jan 13, 2004
23
US
am trying to use the gridview with objectdatasource with subobjects
My class is defined as follows
Public Class AbbrPlant
Private _ID As Integer
Private _PlantName As String
Private _site As Site
'Private _City As String
'Private _State As String
'Private _Country As String



Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal value As Integer)
_ID = value
End Set
End Property

Public Property PlantName() As String
Get
Return _PlantName
End Get
Set(ByVal value As String)
_PlantName = value
End Set
End Property

Public Property Site() As Site
Get
Return _site
End Get
Set(ByVal value As Site)
_site = value
End Set
End Property



End Class
Public Class PlantList
Inherits List(Of AbbrPlant)

Public Sub New()
End Sub

End Class

Site is a class defined as follows
Public Class Site
Private _AddressLine1 As String
Private _AddressLine2 As String
Private _AddressLine3 As String
Private _City As String
Private _State As String
Private _Country As String
Private _ZipCode As String



Public Property AddressLine1() As String
Get
Return _AddressLine1
End Get
Set(ByVal value As String)
_AddressLine1 = value
End Set
End Property

Public Property AddressLine2() As String
Get
Return _AddressLine2
End Get
Set(ByVal value As String)
_AddressLine2 = value
End Set
End Property

Public Property AddressLine3() As String
Get
Return _AddressLine3
End Get
Set(ByVal value As String)
_AddressLine3 = value
End Set
End Property
Public Property City() As String
Get
Return _City
End Get
Set(ByVal value As String)
_City = value
End Set
End Property

Public Property State() As String
Get
Return _State
End Get
Set(ByVal value As String)
_State = value
End Set
End Property

Public Property Country() As String
Get
Return _Country
End Get
Set(ByVal value As String)
_Country = value
End Set
End Property

Public Property ZipCode() As String
Get
Return _ZipCode
End Get
Set(ByVal value As String)
_ZipCode = value
End Set
End Property
Public ReadOnly Property Location() As String
Get
Return IIf(String.IsNullOrEmpty(_City), Trim(Trim(_State) + " " + Trim(IsCountryUSA(_Country))), IIf(String.IsNullOrEmpty(_State), Trim(_City) + " " + Trim(IsCountryUSA(_Country)), Trim(_City) + ", " + Trim(_State) + " " + Trim(IsCountryUSA(_Country))))

End Get

End Property
Private Function IsCountryUSA(ByVal mycountry) As String
Return IIf(Trim(mycountry) = "USA", String.Empty, _Country)
End Function
End Class

I have tried all different kinds of ways to get the gridview to display the suboject of site.location I tried explicitely defining a namespace around the plant class

<asp:Label ID="lblLocation" runat="server"
Text='<%# ((PlantSpace.AbbrPlant)(Container.DataItem)).Site.Location %>'>
</asp:Label>
and I got the following errors
Type AbbrPlant is not defined
Name PlantSpace is not declared

If I change it to <asp:Label ID="lblLocation" runat="server"
Text='<%# ((PrototypeBusinessObjects.PlantSpace.AbbrPlant)(Container.DataItem)).Site.Location %>'>
</asp:Label>
I get the following error
PlantSpace is not a member of PrototypeBusinessObjects

I am extremely frustrated and have tried many different things. If you could please help me out I would appreciate it tremendously.


Thank you
Judith

 
1st, drop the objectdatasource and jump into the code behind with code. to retrieve your data. ODS, or any datasource for that matter, cannot be debugged, or tested.

the error you are receiving states that your namespace.object path is incorrect. I ran into this before when I put code in the App_Code folder. to remedy this I created a new folder with a different name and put my objects in there and everything worked fine.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top