2016-06-15 111 views
0

我試圖從我的網頁上的列表中顯示項目,並且出現一些錯誤。這裏是我的代碼顯示:ASP.NET從列表中顯示數據

<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名repZips.DataSource不會在目前情況下存在

-the名的DataSource不會在目前情況下存在

-the名拉鍊不會在當前的背景下存在

-the名repZips.DataBind不會在目前情況下
-the名的DataBind不會在目前的背景下存在的存在

我是否需要導入某些內容或對其進行不同的定義,以便我可以使用這種格式?我只是試圖在我的頁面上顯示「zip」列表中的所有內容。

+0

你在' techspider

+0

感謝;修復。不過,這不是問題。 – issharp

+0

您可能有其他編譯器錯誤,比如丟失大括號或其他東西。這就是爲什麼它不承認repZips對象 – easymoney202

回答

0

我想通了,對不起,打擾大家 - 感謝您的意見。

如果其他人是否有這樣的問題,確保我已經在代碼中列出背後的東西是該方法的Page_Load中。那麼工作得很好。