Reputation: 7490
I have a class like
class BroadCast
{
public string Comment{ get; set; }
public DateTime Date{ get; set; }
public List<string> DisplayUsers { get; set; }
}
I am binding List<BraodCast>
to Repeater
. Till now I had only two columns in Repeater
but I need to add one more now to display list of DisplayUsers
. I am thinking to use ListView
inside repeater so I bound it like below
<asp:ListView ID="lstDisplayRole" runat="server" DataSource='<%# Eval("DisplayUsers") %>' >
<ItemTemplate>
<asp:Label ID="lblRoleName" runat="server" ForeColor="Black" Text='<%#Eval(index)%>' />
</ItemTemplate>
</asp:ListView>
index
is nothing, I am finding what could be there to make my listview work. I mean if it was a DataTable
instead of List<string>
than it would have been very easy to use Eval("ColumnName")
but this is not a case here, I don't have columns, it's just a list of string. How can I achieve this?
Upvotes: 0
Views: 496
Reputation: 107508
To get the current bound item itself (a string
in this case), use Container.DataItem
. There's nothing to evaluate, so Eval()
isn't needed.
<asp:Label ID="lblRoleName" runat="server" ForeColor="Black" Text='<%# Container.DataItem %>' />
Upvotes: 1