views:

56

answers:

2

Okay I have searched and can't seem to come up with where to find the answer to my question.

What I'm trying to do is to turn the generic string list retrieved from a sql table like so:

List<string> UserList = new List<string>() { "User One", "User Two" };

and trying to output it to a web.aspx page using <%# Eval("UserList"):

<asp:Label id="userList" text='<%# Eval("userList")%>' />

which of course the above gives me 'System.Collections.Generic.List`1[System.String]' as the result.

Edit
What I am looking to do is have the UserList output as a list of users who worked on a picture collaboration. The final output should look something like this:

<img src="picutre" /><br>
<asp:label id="Artist1" text="Artist Name From Asp.net Membership Profile" />
<asp:label id="Artist2" text="Artist Name From Asp.net Membership Profile" />
+3  A: 

You might want to try using string.Join().

<asp:Label id="userList"
           text='<%# string.Join( " ", ((List<string>)Eval("userList")).ToArray() ) %>'
tvanfosson
If you're using .NET 4, you can omit the `ToArray` call since there's a `String.Join` overload that takes an `IEnumerable<string>`.
Julien Lebosquain
+3  A: 

It's not clear what you want to achieve as final result. If you want to output the list as CSV in your label you can use String.Join() method:

http://msdn.microsoft.com/en-us/library/57a79xd0.aspx

like this:

<%# String.Join(", ", ((List<String>)Eval("UserList")).ToArray()) %>
mamoo