473,769 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot bind a collection to a datagrid

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.Collecti ons
Imports ECABINETOLELib
Imports System.Web.Http Context

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(i ndex)
End Sub

Public Property Item(ByVal index As Integer) As Document
Get
Return CType(Me.List(i ndex), 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(eCabWrappe r.DocumentColl oDocColl)
{
dg1.DataSource = oDocColl;
dg1.DataBind();
}

and here is my html implementation

<asp:datagrid id="dg1" runat="server" HorizontalAlign ="Center" PagerStyle-Visible="False" AutoGenerateCol umns="False" CellPadding="2" CellSpacing="2" GridLines="None " BorderStyle="So lid"
BorderWidth="1p x" Font-Size="X-Small" Font-Name="Verdana">
<Columns>
<asp:BoundColum n DataField = "FileName" HeaderText="Fil e Name" HeaderStyle-CssClass="secti onheads"></asp:BoundColumn >
</Columns>
</asp:datagrid>

--------------------------------
From: Doug D

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Y23VE6sATU6 012ZXSVFVkA==</Id>
Nov 20 '05 #1
1 2950
Hi Dough,

How do you call that method "Fill" because in my opinion with this we miss
although you show a lot the most important part.

Cor
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.Collecti ons
Imports ECABINETOLELib
Imports System.Web.Http Context

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(i ndex)
End Sub

Public Property Item(ByVal index As Integer) As Document
Get
Return CType(Me.List(i ndex), 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(eCabWrappe r.DocumentColl oDocColl)
{
dg1.DataSource = oDocColl;
dg1.DataBind();
}

and here is my html implementation

<asp:datagrid id="dg1" runat="server" HorizontalAlign ="Center" PagerStyle-Visible="False" AutoGenerateCol umns="False" CellPadding="2"
CellSpacing="2" GridLines="None " BorderStyle="So lid" BorderWidth="1p x" Font-Size="X-Small" Font-Name="Verdana">
<Columns>
<asp:BoundColum n DataField = "FileName" HeaderText="Fil e Name" HeaderStyle-CssClass="secti onheads"></asp:BoundColumn > </Columns>
</asp:datagrid>

--------------------------------
From: Doug D

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Y23VE6sATU6 012ZXSVFVkA==</Id>

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1229
by: Julia | last post by:
class Document { Hashtable Properties ; //Key is the property name } class Media { Document document;
1
1717
by: yaniv abo | last post by:
Hello. How can I bind a list of objects to a DataGird? I have a custom collection of Customer class
6
3308
by: Andreas Klemt | last post by:
Hello, I have this Public Structure strucUser Dim userIDAs Integer Dim firstnameAs String Dim lastname As String End Structure Dim collectUser As New Collection
2
2101
by: Pete Nelson | last post by:
Does anyone know of a way to bind a string collection to a datagrid? Basically, I have an object, CreditPlans, and a string collection, ModelNumbers. I'd like to bind the ModelNumbers collection to the datagrid, but because there isn't a custom object with properties, just a string object, I'm not sure how to reference it in the datagrid. FYI, I can enumerate through the collection... foreach(string modelNum in...
3
1951
by: AFN | last post by:
In VB.NET, I can successfully bind a generic datagrid to a 1 dimensional array. But, now I want to add a button column, and so I think I need to make the first column (the one having data in the array) a "BoundColumn" and the 2nd column my button column. The problem is that the BoundColumn wants a DataField name. There is none! So how do I bind this one column to the array column when the array doesn't have column names? And if your...
2
2208
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple properties, ProdID, Description, Quantity and UPC. 3 strings and a long. The LineItemsCollection class inherits from System.Collections.Specialized.NameObjectCollectionBase. It also implements both IEnumerable and IList.
11
2499
by: Michael Kellogg | last post by:
I have a collection of custom objects that I am displaying in a Windows Forms Datagrid. To display it, I take the collection and build a DataTable object on the fly, then set the grid's DataSource to the DataTable. The code for this is lengthy and the grid is obviously not editable. I've read it's possible to connect my collection directly, and have it be editable, too. Can anyone point me to a resource that can walk me through this? ...
3
3291
by: serge calderara | last post by:
Dear all, Does anyone know how to bind a System.Collection.ArraysList object to a Dataset ? Thanks for your reply Regards Serge
1
1340
by: Řyvind Isaksen | last post by:
I try to make my own ArticleAttribute object and ArticleAttributeCollection, and add data to this Collection. It almost works, but the problem is that each time I add an ArticleAttribute to my Collection, it seems like it overwrites the other ArticleAttributes. When bind the ArticleAttributeCollection to a datagrid, all articleattributes are the same. This is what my datagrid dispays: ID Content
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.