简体   繁体   English

使用转发器控件asp.net显示列表值

[英]Display List values using repeater control asp.net

I've added the content from DirectoryInfo.GetFiles() to a List<string> . 我已将DirectoryInfo.GetFiles()的内容添加到List<string> Now I wish to display each row from the list using the Repeater control. 现在,我希望使用Repeater控件显示列表中的每一行。 I've done this before with the <%# Eval("Name") %> when I got the data directly from DirectoryInfo.GetFiles() . 当我直接从DirectoryInfo.GetFiles()获得数据时,我已经使用<%# Eval("Name") %>做到了这一点。

But now when they're in a list, the "Name" attribute does not seem to be there anymore. 但是现在当它们在列表中时,“名称”属性似乎不再存在。 So how should I do this with the Eval..? 那么我应该如何使用Eval ..?

Now the Data is the string itself. 现在,数据本身就是字符串。 Get it using this code. 使用此代码获取它。

<%#GetNane(Container.DataItem)%>

and on code behind 以及后面的代码

public string GetNane(object oItem)
{
  return (string)oItem;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM