Last post Mar 11, 2008 11:42 AM by joteke
Mar 10, 2008 11:42 AM|danpickles|LINK
I have created a custom control that I'm setting up to use through the designer. I have a colection exposed which you can add entries for through the desinger, but when you switch views or save I get the error:
Generation of designer file failed: Cannot create an object of type 'System.Collections.Generic.List`1[[Solutions.Toolkit.Web.UI.WebControls.Criteria, Solutions.Toolkit.Web.UI.WebControls.QueryBuilder, Version=22.214.171.124, Culture=neutral, PublicKeyToken=null]]'
from its string representation '(Collection)' for the 'CriteriaList' property.
When you look in the source of the page it has added (Collection) as the data for the updated property:
I am assuming that this needs to be managed in some way, has anyone got any ideas? It all works fine if I add to the CriteriaList property code side.
Mar 10, 2008 01:16 PM|joteke|LINK
Have you applied
PersistenceMode attribute for the CriteriaList property by specifying the persistence mode to be
Mar 10, 2008 01:53 PM|danpickles|LINK
No I hadn't. Fantastic, that's got rid of that problem[:)]. I now appear to be having problems loading the data back into the control after changing views. I'm getting the error QueryBuilder1:'cc1:QueryBuilder' could not be set on property 'CriteriaList'. [:(]
The source data now looks right:
Any ideas? Thanks for your help.
Mar 11, 2008 09:08 AM|danpickles|LINK
Right, worked the last bit out. I had a collection as a property, and I had declared it to have both
set and get bits. I didn't need the set part (we are using the Add, Delete, Clear methods on the collection) and this appeared to be upsetting VS.
Thanks for all your help.
Mar 11, 2008 11:42 AM|joteke|LINK
Yes, collection (complex) proeprties are usually read-only so that they're lazy-instantiated on first access to the property.