ASP.NET直放站绑定列表&LT;串GT; [英] ASP.NET Repeater bind List<string>
本文介绍了ASP.NET直放站绑定列表&LT;串GT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我绑定一个列表与LT;串&GT;
来Repeater控件。现在我想使用评估
功能
显示在的ItemTemplate
的内容像
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.
推荐答案
只需使用&LT;%#Container.DataItem.ToString()%GT;
如果你担心空值可能要重构这个
If you are worried about null values you may want to refactor to this
&LT;%#的Container.DataItem的ToString()?的String.Empty%>
<%# Container.DataItem?.ToString() ?? string.Empty%>
这篇关于ASP.NET直放站绑定列表&LT;串GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文