I Have a display that needs to be a little more dynamic than what I'm use to and can't seem to quite find the answer I need.
Customer a Customer b Customer c (and so on)
savings with product a
savings with product b
(and so on)
I know there will always be a minimum of one in each field. Someone said use a nested repeater or something. I looked around and couldn't find out how to use a nested repeater. I am on a deadline and can't really play with things until I find something that works.
What asp control should I use to do this? An example would be nice but I just need help in the right direction.
I am using sql but getting the data through link. The data ends up in lists.
Thank you for your help!
Nested Repeaters are pretty easy. Just throw one in your ItemTemplate, and in the OnItemDataBound event of your main repeater do the following
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView row = (DataRowView)e.Item.DataItem;
Repeater nestedRepeater = e.Item.FindControl("NestedRepeater") as Repeater;
nestedRepeater.DataSource = getSavingsPerCustomer(row["customerID"]);
nestedRepeater.DataBind();
}
Where the template of the outer repeater had a customer name and a repeater and the inner one has the different savings
probably incorrect syntax but you get the idea
<asp:repeater ID="outer">
<HeaderTemplate>
<div style="float:left">
</HeaderTemplate>
<ItemTemplate>
Customer: <%= Eval(customer)%><br/>
<asp:repeater ID="NestedRepeater">
<ItemTemplate>
Saving: <%= Eval(saving)%><br/>
</ItemTemplate>
</asp:repeater>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:repeater>
Similar SO question: Repeater in Repeater
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With