ASP.NET 显示列表中的数据

ASP.NET display data from a list

我试图在我的网页上显示列表中的项目,但遇到了一些错误。这是我的显示代码:

<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> 

代码隐藏:

    List<int> zips = (List<int>)ListZips.getZips();
    repZips.DataSource = zips;
    repZips.DataBind();

此代码隐藏中有几个错误:

-the name repZips.DataSource does not exist in the current context

-the name DataSource does not exist in the current context

-the name zips does not exist in the current context

-the name repZips.DataBind does not exist in the current context
-the name DataBind does not exist in the current context

我是否需要导入某些内容或以不同方式定义某些内容才能使用这种格式?我只是想在我的页面上显示列表 "zips" 中的所有内容。

我明白了,不好意思打扰大家了~谢谢大家的意见。

如果其他人遇到这样的问题,请确保我在后面的代码中列出的内容在方法 Page_Load 中。当时工作得很好。