2

I have a FormView that has a datasource bind as a object which is a WCF service. In the WCF Service i have a Object PublicationDetail which has a attribute List authors;

I want to join the contents of the list and print them out in the form view however i fall on the following error:

Unable to cast object of type 'System.String[]' to type 'System.Collections.Generic.List`1[System.String]'.

And the code:

<asp:Label ID="AuthorsLabel" runat="server" Text='<%# String.Join( ",", ((List<string>)Eval("Authors")).ToArray()) %>' />
HeavenCore
  • 7,533
  • 6
  • 47
  • 62
Sterling Duchess
  • 1,970
  • 16
  • 51
  • 91

1 Answers1

1

Just use

String.Join( ",", ((string[])Eval("Authors")))

WCF serializes List<T> as T[] in messages, so your bound property is an array.

See Why does WCF return myObject[] instead of List<T> like I was expecting?

Community
  • 1
  • 1
Rhumborl
  • 16,349
  • 4
  • 39
  • 45