Collection Persistence

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Collection Persistence

    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:

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

    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 Guest

  2. Similar Questions and Discussions

    1. Persisting collection data of a webcontrol when leaving the collection editor in VS2005
      Hi folks, I'm developing a WebControl, that has got a property that's supposed to return a collection of data. Whenever I try to populate the...
    2. Adding to collection from controlDesigner only produces end tag for the collection.
      I have a customDesigner that adds to a collection in my control. For some reason on the closing tag is added to the HTML view. My control is...
    3. How to bing a collection with sub-collection to grid
      I have a collection of objects (say Customers for example). Each Customer Object has a collection of orders. When I bind such complex type to...
    4. Persistence
      Hi, I have a datagrid with a checkbox column. The datagrid is using paging and sorting. When I click on a checkbox then go to page 2 (or any...
    5. help for properties persistence
      Hi. I'm developing a WebControl that uses the following custom attributes: I'm using ParseChildren(false), because i've got two collection...
  3. #2

    Default Re: Collection Persistence

    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" <p.endersby@removespamfdsltd.co.uk> wrote in message
    news:3f6060ca$0$33800$65c69314@mercury.nildram.net ...
    > 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:
    >
    >
    [url]http://www.codeproject.com/cs/miscctrl/extendedlistviews.asp?df=100&forumid=13645&fr=51[/url]
    >
    > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139