D
Doug D via .NET 247
I really really need some insight on this problem
I am trying to bind a strongly typed collection object to a datagrid.
I already Inherited CollectionBase, but .NET says that it cannot find my property name, when I try to bind it to the grid..
now, here is where it gets tricky.
Do I NEED to Implement IBindingList, on my collection object, since my object that I am adding to the collection inherits from a another class?
here is my code
Imports System.Collections
Imports ECABINETOLELib
Imports System.Web.HttpContext
Public Class DocumentColl
Inherits CollectionBase
Private m_Connection As ECABINETOLELib.IConnection
Public Function Add(ByVal adoc As Document) As Integer
Return List.Add(adoc)
End Function
Public Sub Remove(ByVal index As Integer)
List.RemoveAt(index)
End Sub
Public Property Item(ByVal index As Integer) As Document
Get
Return CType(Me.List(index), Document)
End Get
Set(ByVal Value As Document)
List.Item(index) = Value
End Set
End Property
End Class
and here is my Document object that I am adding to the collection
Public Class Document
Inherits ECABINETOLELib.DocumentClass
Private m_Filename As String
Public Property FileName() As String
Get
Return m_Filename
End Get
Set(ByVal Value As String)
m_Filename = Value
End Set
End Property
Private m_Path As String
Public Property Path() As String
Get
Return m_Path
End Get
Set(ByVal Value As String)
m_Path = Value
End Set
End Property
End Class
here is my code when binding (yes my code is in c# and my wrapper is in vb.net)
private void Fill(eCabWrapper.DocumentColl oDocColl)
{
dg1.DataSource = oDocColl;
dg1.DataBind();
}
and here is my html implementation
<asp:datagrid id="dg1" runat="server" HorizontalAlign="Center" PagerStyle-Visible="False" AutoGenerateColumns="False" CellPadding="2" CellSpacing="2" GridLines="None" BorderStyle="Solid"
BorderWidth="1px" Font-Size="X-Small" Font-Name="Verdana">
<Columns>
<asp:BoundColumn DataField = "FileName" HeaderText="File Name" HeaderStyle-CssClass="sectionheads"></asp:BoundColumn>
</Columns>
</asp:datagrid>
I am trying to bind a strongly typed collection object to a datagrid.
I already Inherited CollectionBase, but .NET says that it cannot find my property name, when I try to bind it to the grid..
now, here is where it gets tricky.
Do I NEED to Implement IBindingList, on my collection object, since my object that I am adding to the collection inherits from a another class?
here is my code
Imports System.Collections
Imports ECABINETOLELib
Imports System.Web.HttpContext
Public Class DocumentColl
Inherits CollectionBase
Private m_Connection As ECABINETOLELib.IConnection
Public Function Add(ByVal adoc As Document) As Integer
Return List.Add(adoc)
End Function
Public Sub Remove(ByVal index As Integer)
List.RemoveAt(index)
End Sub
Public Property Item(ByVal index As Integer) As Document
Get
Return CType(Me.List(index), Document)
End Get
Set(ByVal Value As Document)
List.Item(index) = Value
End Set
End Property
End Class
and here is my Document object that I am adding to the collection
Public Class Document
Inherits ECABINETOLELib.DocumentClass
Private m_Filename As String
Public Property FileName() As String
Get
Return m_Filename
End Get
Set(ByVal Value As String)
m_Filename = Value
End Set
End Property
Private m_Path As String
Public Property Path() As String
Get
Return m_Path
End Get
Set(ByVal Value As String)
m_Path = Value
End Set
End Property
End Class
here is my code when binding (yes my code is in c# and my wrapper is in vb.net)
private void Fill(eCabWrapper.DocumentColl oDocColl)
{
dg1.DataSource = oDocColl;
dg1.DataBind();
}
and here is my html implementation
<asp:datagrid id="dg1" runat="server" HorizontalAlign="Center" PagerStyle-Visible="False" AutoGenerateColumns="False" CellPadding="2" CellSpacing="2" GridLines="None" BorderStyle="Solid"
BorderWidth="1px" Font-Size="X-Small" Font-Name="Verdana">
<Columns>
<asp:BoundColumn DataField = "FileName" HeaderText="File Name" HeaderStyle-CssClass="sectionheads"></asp:BoundColumn>
</Columns>
</asp:datagrid>