62,176
社区成员
发帖
与我相关
我的任务
分享
<!-- your aspx file -->
<table>
<asp:Repeater ID="repeaterFriendLinks" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:HyperLink ID="linkFriendLink" runat="server" Text='<%# Eval("SiteName") %>' NavigateUrl='<% Eval("SiteUrl") %>'/>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
//Test object class
public class MyFriendLink
{
private string siteName;
private string siteUrl;
public MyFriendLink(string name, string url)
{
siteName = name;
siteUrl = url;
}
public string SiteName
{
set { siteName = value; }
get { return siteName; }
}
public string SiteUrl
{
set { siteUrl = value; }
get { return siteUrl; }
}
}
//your page code file
public class YourPage.aspx.cs
{
public void Page_Load(object sender, EventArgs e)
{
List<MyFriendLink> friendLinkList = new List<MyFriendLink>();
friendLinkList.Add( new MyFriendLink("site1", "http://abc.def.com") );
friendLinkList.Add( new MyFriendLink("site2", "http://123.456.com") );
repeaterFriendLinks.DataSource = friendLinkList;
repeaterFriendLinks.DataBind();
}
}
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="10">
<ItemTemplate>
<%# Eval("name") %>
</ItemTemplate>
</asp:DataList>