[英]ASP.NET display data from a list
I'm trying to display items from a list on my webpage, and I'm getting some errors. 我试图在网页上显示列表中的项目,但出现一些错误。 Here's my code for the display:
这是我的显示器代码:
<asp:Repeater id="repZips" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<td>
<%# Container.ItemIndex + 1 %>- <%# Container.DataItem %>
</td>
</ItemTemplate>
<FooterTemplate>
</tr></table>
</FooterTemplate>
</asp:Repeater>
CodeBehind: 代码背后:
List<int> zips = (List<int>)ListZips.getZips();
repZips.DataSource = zips;
repZips.DataBind();
There are several errors in this codebehind: 此代码背后有几个错误:
-the name repZips.DataSource does not exist in the current context
-名称repZips.DataSource在当前上下文中不存在
-the name DataSource does not exist in the current context
-名称DataSource在当前上下文中不存在
-the name zips does not exist in the current context
-名称zips在当前上下文中不存在
-the name repZips.DataBind does not exist in the current context
-名称repZips.DataBind在当前上下文中不存在
-the name DataBind does not exist in the current context-名称DataBind在当前上下文中不存在
Do I need to import something or define things differently so that I can use this sort of format? 我是否需要导入某些内容或以不同的方式定义事物,以便可以使用这种格式? I'm just trying to display everything in the list "zips" on my page.
我只是想在页面的“ zips”列表中显示所有内容。
I figured it out, sorry to bother everyone--thanks for the comments. 我想通了,很抱歉打扰大家-感谢您的评论。
If anyone else is having a problem like this, make sure that the stuff I have listed in the code behind is inside the method Page_Load. 如果还有其他人遇到这样的问题,请确保我在后面的代码中列出的内容位于Page_Load方法中。 Worked fine then.
然后工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.