<asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <asp:HyperLink ID="linkInRepeater" runat="server">link</asp:HyperLink> </ItemTemplate> </asp:Repeater>
要取得 HyperLink 控制項,需添加
OnItemDataBound
屬性給 Repeater :<asp:repeater ID="Repeater1" runat="server" OnItemDataBound="getControl" >
接著在 .cs 裡設定
getControl
:protected void getControl(object sender, RepeaterItemEventArgs e) { HyperLink myLink = (HyperLink)e.Item.FindControl("linkInRepeater"); myLink.Text = "change text"; // 變更連結文字 }
沒有留言:
張貼留言