Collection Persistence

Discussion in 'ASP .Net Building Controls' started by Paul Endersby, Sep 11, 2003.

  1. All,

    I'm sorry for asking this cause I know it has been asked a thousand times
    before, but I don't seem to be able to find a complete solution that works.

    I have a custom collection implemented as follows:

    public class PropertyInfo
    {
    private string _Property = "";
    private string _BusinessObject = null;

    public PropertyInfo(){}

    public string Property
    {
    get{return _Property;}
    set{_Property = value;}
    }
    public string BusinessObject
    {
    get{return _BusinessObject;}
    set{_BusinessObject = value;}
    }
    }

    public class fdsPropertyCollection: System.Collections.CollectionBase
    {
    public PropertyInfo this[int index]
    {
    get {return List[index] as PropertyInfo;}
    set {List[index] = value;}
    }
    public int Add(PropertyInfo item)
    {
    return List.Add(item);
    }
    }

    Then, in my component I have a public property declared as:

    protected fdsPropertyCollection _Properties = new fdsPropertyCollection();
    public fdsPropertyCollection Properties
    {
    get{return _Properties;}
    }

    I can use my component and add new items to the collection fine no problems
    there. My problem comes when I look at the HTML generated for my property it
    has written:

    Properties="(Collection)" Properties-Count="2"

    This is clearly not what I want to happen, but I have no idea what I am
    supposed to do. I've tried adding type converters to the PropertyInfo class,
    I've tried adding an CollectionEditor class to the Custom collection. I've
    had varying combinations of the ParseChildren and PersistChildren attributes
    in my component and I've tried adding the PersistenceMode attribute to the
    components property. All have which have resulted in varying flavours of
    failure!

    My code almost exactly represents the code in the article:

    http://www.codeproject.com/cs/miscctrl/extendedlistviews.asp?df=100&forumid=13645&fr=51

    This however hasn't helped me :*-(

    Please help, I'm pulling my hair out on what should be a really simple task.

    Regards,

    Paul.
     
    Paul Endersby, Sep 11, 2003
    #1
    1. Advertisements

  2. Any one any idea why this is soooooooo hard? All I want is a collection with
    two strings in it that's editable and persists at design time.
     
    Paul Endersby, Sep 12, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.