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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding Custom Collection to control? 1

Status
Not open for further replies.

Tokhra

Programmer
Oct 1, 2003
134
ES
Hi all,

I have a custom collection derived from ArrayList. But when I tried to bind this collection to a asp.net DataList control I get nothing, so I guess you have to do something special to enable this?

I have set up the properties on the class that the collection stores, I wonder if you have to write somekind of additional properties on the collection itself?

I could always write a ToDataSet() method for my collection, but id rather do it the proper way if there is one

Thanks,
Matt.

Code:
====================================================

using System;
using System.Collections;

namespace Blah.Components
{
/// <summary>
/// Provides a Type Safe collection used to store instances of Owner class.
/// </summary>
public class OwnerCollection : ArrayList
{
/// <summary>
/// Initialise Collection.
/// </summary>
public OwnerCollection()
{
// Do nothing.
}

/// <summary>
/// Add Owner item to collection.
/// </summary>
/// <param name="owner">Owner item to add</param>
public void Add(Owner owner)
{
base.Add(owner);
}

/// <summary>
/// Remove Owner item from collection.
/// </summary>
/// <param name="owner">Owner item to remove</param>
public void Remove(Owner owner)
{
base.Remove(owner);
}

/// <summary>
/// Property accessor method for collection items.
/// </summary>
public Owner this[int index]
{
get
{
return (Owner) base[index];
}
set
{
base[index] = value;
}
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top