Hey guys,
I have read the following posts and a bunch of similar stuff on StackOverflow regarding databind to a repeater control. I mean, sheesh, I've done it literally hundreds of times and know all of the common (and some uncommon) pitfalls. However, I've got a problem this time with an UpdatePanel-based UserControl that I haven't been able to resolve.
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12929
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=10758
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12254
I'll try to be clear on the scenario, which is binding an AddressCollection of AddressEntity objects to a repeater to show all of a customer's addresses.
HTML:
<asp:Repeater ID="rptCustomerAddressess" runat="server">
<ItemTemplate>
<uc1:Address ID="CustomerAddress" runat="server" UpdateMode="Conditional" Address='<%# Container.DataItem %>' />
</ItemTemplate>
</asp:Repeater>
Then on _rptCustomerAddressess_ItemDataBound...
Pages_Controls_Address customerAddress = (Pages_Controls_Address) e.Item.FindControl("CustomerAddress");
customerAddress.DisplayViewAddress();
customerAddress.Update();
This works to display the data, but the UserControl sets all of its values to "null" when trying to save the entity...
... dawn breaks over Marblehead ...
I neglected the if(!IsPostBack) before LoadAddresses() call in the Page_Load() method. Hopefully the rest of the post is useful to someone else.