Filling listview (ASP.net)

Hi inside a <ItemTemplate> of a Listview I try to do this:

<asp:Label ID="RolesLabel" runat="server" Text='<%# GetRoles(Eval('Id')) %>' />

In code-behind I have a function:
   public string GetRoles(string id);

GetRoles looks up a bunch of roles and returns a string with rolenames. Byt I cant get this to work.
The error lies here:
GetRoles(Eval('Id')) , wrong syntax?
o3hAsked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Nested quotes problem:

<asp:Label ID="RolesLabel" runat="server" Text='<%# GetRoles(Eval("Id")) %>' />

Open in new window

0
 
devlab2012Commented:

Correct the quotes and use Eval("id").ToString()

<asp:Label ID="RolesLabel" runat="server" Text='<%# GetRoles(Eval("Id").ToString()) %>' />
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.