I am binding a List<string>
to a Repeater control. Now I want to use the Eval
function
to display the contents in ItemTemplate
like
<%# Eval("NAME") %>.
But I am not sure what I should use instead of NAME.
asp.netdata-bindingrepeater
I am binding a List<string>
to a Repeater control. Now I want to use the Eval
function
to display the contents in ItemTemplate
like
<%# Eval("NAME") %>.
But I am not sure what I should use instead of NAME.
Best Answer
Just use
<%# Container.DataItem.ToString() %>
If you are worried about null values you may want to refactor to this (.NET 6+)
Note if you are using less than .NET 6 you cannot use the null-conditional operator Container.DataItem?.ToString()