Damián Herrera
Damián Herrera

Reputation: 89

Cannot create an object of type 'System.String[]' from its string representation '[1,2]'

I need an ASP.Net control on your property you can specify an array type string. That is, in my ASP.Net control would have something like:

DefaultValue("")> Category("Misc"), <Bindable(True),
Public Overridable Property MyProperty () As String ()
   Get
      Return mMyProperty
   End Get
   Set (ByVal value As String ())
     mMyProperty = value
   End Set
End Property

And from the ASP.Net page I need to pass the values​​, type:

<WC:MyControl MyProperty="1,2,4" runat="server" />

The message error is: Cannot create an object of type 'System.String[]' from its string representation '1,2,4' for the 'MyProperty' property.

Upvotes: 2

Views: 3514

Answers (1)

Oleks
Oleks

Reputation: 32343

You need to implement a TypeConvertor for this.

These resources could help you with it:

  1. How to: Implement a Type Converter
  2. Passing int list as a parameter to a web user control
  3. Passing int array as parameter in web user control

Upvotes: 5

Related Questions