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;
}
}
}
}
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;
}
}
}
}