2009-09-18 29 views
1

我無法找到位於FormView控制器內部的名爲「repScore」的中繼器控制器。無法在FormView中查找中繼器

這是我的代碼:

<asp:FormView runat="server" id="fwHotelDetails" DataKeyNames="id" OnDataBound="fwHotelDetails_DataBound" > 
    <ItemTemplate> 
     // (..) some code here which outputs some data 

     <asp:Repeater runat="server" id="repScore"> 
      <ItemTemplate> 
      <span class="item"> <%# Eval("criteria") %>:</span> 
      </ItemTemplate> 
     </asp:Repeater> 

    </ItemTemplate> 
</asp:FormView> 

這是我的代碼背後:

protected void fwHotelDetails_DataBound(object sender, EventArgs e) 
    { 
     Repeater rep = (Repeater)fwHotelDetails.FindControl("repScore"); 

     rep.DataSource = this.dtCriteria; 
     rep.DataBind(); 
    } 

我在做什麼錯?

+0

如果上面的代碼已被編輯以反映工作代碼,您應該在您的帖子中說。 – GFoley83 2013-06-30 22:27:50

回答

2

我看不到那個formView引發了DataBound事件,難道你忘記了聲明事件處理程序嗎?

+0

你是對的。所以我添加了OnDataBound =「fwHotelDetails_DataBound」。現在我收到以下錯誤消息:CS1061:'ASP.templates_hoteldetails_aspx'不包含'fwHotelDetails_DataBound'的定義,並且沒有找到接受'ASP.templates_hoteldetails_aspx'類型的第一個參數的擴展方法'fwHotelDetails_DataBound'使用指令或彙編參考?) – Steven 2009-09-18 11:07:23

+0

謝謝你的擡頭。我得到了這個錯誤消息,因爲函數被設置爲private。一旦我使用了Protected,它就可以工作。 – Steven 2009-09-18 11:12:03

1

我不能評論尚未...所以這裏有雲:

基本上就意味着它必須聲明你的方法沒有訪問...

改變「私人」到「保護」(或「內部」,或「公共」,取決於你需要什麼)應該有所幫助。

相關問題