views:

31

answers:

2

I know that in ASP.NET (talking about 2.0 here primarily) one can set a property on an object that takes a collection of things (an enumerable type I'm guessing is the trigger) and then reference it declaritivly. For example:

<ObjectDataSource properties="blahblahblah">
    <SelectParameters>
        <asp:Parameter />
    </SelectParameters>
</ObjectDataSource>

It is the <asp:Parameter /> part which is the root of my question. Say I wanted a simpler collection on a type. Say a List<String> or if generics are out, an IntegerCollection or StringCollection. How would I use that declaratively? Is <string value=''> allowed, or can I put raw values into it like <StringCollection>string, string, string</StringCollection> or what?

EDIT:

I feel like I was not clear enough in my question. I understand that ObjectDataSource implements its SelectParameters property as a ParametersCollection, and that one can use that property declaratively (in an ASPX page) to set up Parameter types within that collection. What I'm wondering is if I made something like StringCollection as a property on another control, is there a syntax (in ASPX) for adding strings to that collection? Or would I have to define a wrapping class like how DropDownList takes ListItems to fill its collection?

+1  A: 

In an objectdatasource the selectparameter refers to a parameter in a method that returns a collection. That parameter needs to be something that can be converted from a string, it cannot be a collection or an array.

Ben Robinson
A: 

I eventually found what I needed for this. The general answer is to use a TypeConverter attribute on the property. The GridView does this with (as one example) DataKeyNames, converting a comma separated list of names in a string into an array of strings.

CodexArcanum