2012-10-10 17 views

回答

3

如果你想這樣做,你應該這樣寫:

Visible=<%= SetVisiblity() %> 

其中SetVisiblity是公共職能

+1

其中SetVisibility返回布爾值。保護應該足夠了 – middelpat

+0

不錯的建議,謝謝! – davioooh

0

這應該做的伎倆。首先,創建一個方法來捕獲中繼器的OnDataItemBound事件。

protected void MyRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) 
{ 
    // Use FindControl, but start from the context of the RepeaterItem. 
    // 
    HtmlTableCell cell = e.item.FindControl("CellID") as HtmlTableCell; 

    if (cell != null) 
    { 
     // Do what you gotta do. 
    } 
} 

可以明確連線事件了中繼器上的標記。

<asp:Repeater ID="MyRepeater" runat="server" OnItemDataBound="MyRepeater_ItemDataBound"> 
</asp:Repeater> 
+0

'FindControl'返回'null'這不起作用 – davioooh

+0

你是否逐字複製我的代碼?請發佈您的代碼。 –

相關問題