This is a followup question to one I posted a couple of weeks ago. I have an Object (bootset), which I want to bind to my gridview. It contains 2 sets of chilld objects, which i must access. Here is the Boot/Bootset classes:
And the Head/HeadSet Classes:Code:Option Explicit On Public Class Boot 'Contains a head and shell #Region "Private Variables" Private _oHeadSet As New HeadSet Private _oShellSet As New ShellSet Private _iBootID As Integer #End Region #Region "Constructors" Public Sub New() _oHeadSet = New WQS_BusinessEntity.HeadSet Dim oHead As New Head _oHeadSet.Add(oHead) _oShellSet = New WQS_BusinessEntity.ShellSet Dim oShell As New Shell _oShellSet.Add(oShell) End Sub Public Sub New(ByVal oHeadSet As HeadSet, ByVal oShellSet As ShellSet, ByVal iBootID As Integer, ByVal iBootTypeID As Integer, ByVal iVesselID As Integer) _oHeadSet = New WQS_BusinessEntity.HeadSet _oShellSet = New WQS_BusinessEntity.ShellSet Dim oHead As New Head Dim oShell As New Shell _oHeadSet.Add(oHead) _oShellSet.Add(oShell) _iBootID = iBootID End Sub #End Region #Region "Public Properties" Public Property oHeadSet() As WQS_BusinessEntity.HeadSet Get Return _oHeadSet End Get Set(ByVal oValue As HeadSet) _oHeadSet = oValue End Set End Property Public Property oShellSet() As WQS_BusinessEntity.ShellSet Get Return _oShellSet End Get Set(ByVal oValue As ShellSet) _oShellSet = oValue End Set End Property Public Property iBootID() As Integer Get Return _iBootID End Get Set(ByVal iValue As Integer) _iBootID = iValue End Set End Property #End Region End Class Public Class BootSet Inherits Collections.ArrayList Public Shadows Function Add(ByVal oValue As Boot) As Integer If Not oValue Is Nothing Then MyBase.Add(oValue) End If End Function Default Public Shadows Property Item(ByVal iIndex As Integer) As Boot Get Return CType(MyBase.Item(iIndex), Boot) End Get Set(ByVal Value As Boot) MyBase.Item(iIndex) = Value End Set End Property End Class
And my Shell/ShellSet:Code:Option Explicit On Public Class Head Inherits WQS_BusinessEntity.HeadSet #Region "Private Variables" Private _iHeadID As Integer #End Region #Region "Constructors" Public Sub New() End Sub Public Sub New(ByVal iHeadID As Integer) _iHeadID = iHeadID End Sub #End Region #Region "Public Properties" Public Property iHeadID() As Integer Get Return _iHeadID End Get Set(ByVal iValue As Integer) _iHeadID = iValue End Set End Property #End Region End Class Public Class HeadSet Inherits Collections.ArrayList Public Shadows Function Add(ByVal oValue As Head) As Integer If Not oValue Is Nothing Then MyBase.Add(oValue) End If End Function Default Public Shadows Property Item(ByVal iIndex As Integer) As Head Get Return CType(MyBase.Item(iIndex), Head) End Get Set(ByVal Value As Head) MyBase.Item(iIndex) = Value End Set End Property End Class
Notice that this Bootset Object contains one to many boots, each of which contains a headset and a shellset. a headset/shellset can contain one or more heads/shells. I need to Access (display) the properties in the contained obects, and do so in my gridview. Here is my code from my gridview, but as you can see i just dont know how to do what Im trying to accomplish.Code:Option Explicit On Public Class Shell Inherits WQS_BusinessEntity.ShellSet #Region "Private Variables" Private _iShellID As Integer #End Region #Region "Constructors" Public Sub New() End Sub Public Sub New(ByVal iShellID As Integer) _iShellID = iShellID End Sub #End Region #Region "Public Properties" Public Property iShellID() As Integer Get Return _iShellID End Get Set(ByVal iValue As Integer) _iShellID = iValue End Set End Property #End Region End Class Public Class ShellSet Inherits Collections.ArrayList Public Shadows Function Add(ByVal oValue As Shell) As Integer If Not oValue Is Nothing Then MyBase.Add(oValue) End If End Function Default Public Shadows Property Item(ByVal iIndex As Integer) As Shell Get Return CType(MyBase.Item(iIndex), Shell) End Get Set(ByVal Value As Shell) MyBase.Item(iIndex) = Value End Set End Property End Class
I could really use help on this one!Code:<asp:GridView ID="grdBoots" runat="server" AutoGenerateColumns="false" > <AlternatingRowStyle CssClass="alt" /> <Columns> <asp:TemplateField HeaderText="BootID" Visible="false"> <%--**********************************Boot Number************************************************************************* --%> <HeaderTemplate> <asp:Label id="lblBootID" runat="server" Text='<%# Eval("iBootID") %>'></asp:Label> </HeaderTemplate> </asp:TemplateField> <%--**********************************Head Number*************************************************************************--%> <asp:TemplateField HeaderText="HeadID" Visible="false" > <ItemTemplate> <asp:HiddenField ID="hfHeadID" runat="server" Visible="False" Value='<%# Eval(".oHeadSet(0).iHeadID") %>' ></asp:HiddenField> </ItemTemplate> </asp:TemplateField> <%--**********************************Shell Number*************************************************************************--%> <asp:TemplateField HeaderText="ShellID" Visible="false" > <ItemTemplate> <asp:HiddenField ID="hfShellID" runat="server" Visible="False" Value='<%# Eval("oShellSet(0).iShellID") %>' ></asp:HiddenField> </ItemTemplate> <FooterTemplate> <asp:HiddenField ID="hfShellID" runat="server" Visible="False" Value='<%# Eval("oShellSet(0).iShellID") %>' ></asp:HiddenField> </FooterTemplate> </asp:TemplateField> </Columns> </asp:GridView>




Reply With Quote
