Reputation: 2440
the following code should show the list of websites in a repeater but it does not (though I get no errors): In the aspx file I have:
<div>
<asp:Repeater ID="Rpt1" Visible="true" runat="server"></asp:Repeater>
<ItemTemplate>
<asp:HyperLink runat="server" Text = '<%# DataBinder.Eval(Container.GetDataItem(), "Key") %>'
NavigateUrl= '<%#DataBinder.Eval(Container.GetDataItem(), "Value") %>'>
</asp:Hyperlink>
</ItemTemplate>
</div>
In the code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
CaricaSiti();
}
protected void CaricaSiti()
{
ListDictionary L = new ListDictionary();
L.Add("google", @"http://google.com");
L.Add("microsoft", @"http://microsoft.com");
L.Add("yahoo", @"http://yahoo.com");
Rpt1.DataSource = L;
Rpt1.DataBind();
}
Upvotes: 0
Views: 38
Reputation: 460058
The repeater's ItemTemplate
must be inside of the repeater :-)
<asp:Repeater ID="Rpt1" Visible="true" runat="server">
<ItemTemplate>
<asp:HyperLink runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Key") %>'
NavigateUrl= '<%#DataBinder.Eval(Container.DataItem, "Value") %>'>
</asp:Hyperlink>
</ItemTemplate>
</asp:Repeater>
Upvotes: 3