Working with ADO.NET Datasets and .NET Objects using Crystal Reports and ASP.NET 2.0 - .NET objects as data sources to Crystal Reports: adding a collection class
(Page 5 of 6 )
In previous section, we added a class which holds only one row of information from the "Orders" table (but with few fields). Now, we are adding one more class to hold a set of rows from the "Orders" table based on the "Order" entity class. This class must be named "Orders.vb" and must inherit from the "CollectionBase" class (part of the .NET Framework Class Library).
Add a new class named "Orders.vb" and copy the following code:
Imports Microsoft.VisualBasic
Public Class Orders
Inherits CollectionBase
Public Sub add(ByVal e As Order)
List.Add(e)
End Sub
Public Sub delete(ByVal e As Order)
List.Remove(e)
End Sub
Public Sub delete(ByVal index As Integer)
If index < 0 Or index > List.Count - 1 Then
Throw New Exception("Invalid index to remove")
End If
List.RemoveAt(index)
End Sub
Default Public Overridable ReadOnly Property Item(ByVal index As Integer) As Order
Get
Return CType(Me.List(index), Order)
End Get
End Property
End Class
It is basically a collection class which holds a group of objects related to the "Order" class.
Next: .NET objects as data sources to Crystal Reports: adding and binding a crystal report >>
More ASP.NET Articles
More By Jagadish Chaterjee