TypeConverter for a generics list

Discussion in 'ASP .Net Building Controls' started by Imar Spaanjaars, Jan 30, 2008.

  1. Hello everyone,

    I am trying to write a TypeConverter for a property of type StringCollection
    or List<string> that I want to persist as a comma separated value. E.g. in
    markup I want to be able to use this:

    <isp:SomeControl Value="1,2,3" runat="server" ID=MyControl" />

    While in code, I want to be able to use something like:

    MyControl.Value.Add(1);

    Can anyone point me in the right direction on how to do this? I looked at
    the StringArrayConverter in the WebControls namespace which seems close to
    what I want to accomplish.

    I tried different flavors of code involving ITypeDescriptorContext, various
    CanConvert* methods etc but none seem to work so far. I either get no
    results, or I get run-time errors.

    In case anyone wants to give this a try, here's the code for the actual
    control with the StringCollection property and the converter:

    (Converter)
    http://imar.spaanjaars.com/Downloads/Other/ServerControls/StringCollectionTypeConverter.txt

    (Control)
    http://imar.spaanjaars.com/Downloads/Other/ServerControls/ModuleSettings.txt

    Any help would be greatly appreciated.

    Regards,

    Imar
    http://imar.spaanjaars.com/
     
    Imar Spaanjaars, Jan 30, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kent Boogaart

    TypeConverter and Generics

    Kent Boogaart, Jan 19, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    4,658
  2. Juergen Berchtel
    Replies:
    1
    Views:
    6,033
    John C. Bollinger
    May 20, 2005
  3. Kent Boogaart

    TypeConverter and Generics

    Kent Boogaart, Jan 16, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    177
    Kent Boogaart
    Jan 16, 2006
  4. Chuck P

    TypeConverter Enum / CheckBox List

    Chuck P, Sep 4, 2007, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    1,216
    Walter Wang [MSFT]
    Sep 11, 2007
  5. Imar Spaanjaars

    TypeConverter for a StringCollection or a Generics list

    Imar Spaanjaars, Apr 8, 2008, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    949
    Imar Spaanjaars
    Apr 8, 2008
Loading...

Share This Page