日期:2014-05-17  浏览次数:20840 次

如何在Repeater中嵌套超链接
如何在Repeater中嵌套超链接,求代码,求方法!谢谢

------解决方案--------------------
可以使用HyperLink,前台展示HyperLink,在Repeater的OnItemDataBound写HyperLink的相关代码:
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="hyperlink" runat="server"></asp:HyperLink></div> </ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
后台:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
HyperLink hyperlink = e.Item.FindControl("hyperlink") as HyperLink;
if (hyperlink != null)
{
hyperlink.NavigateUrl = "http://www.baidu.com";
hyperlink.Text = "跳转到百度";
}
}