I have the following ASP.NET 2.0 code (simplified here for ease):
<asp:Repeater id="SearchResul tsRepeater" runat="server">
<ItemTemplate >
<uc:SearchResul t ID="SearchResul t"
ResultObject="< %#Container.Dat aItem%>" runat="server">
<ButtonsTemplat e>
<uc:ViewButto n ID="ViewButton "
ListingReferenc e='<%#Eval("Lis tingReference") %>' runat="server" />
</ButtonsTemplate >
</uc:SearchResult >
</ItemTemplate>
</asp:Repeater>
This works fine except for the databinding on user control "ViewButton "
property ListingReferenc e. Does anyone know how to get the databinding to
work in this example?
For reference moving <uc:ViewButtono utside the inline template will work
with no problem, but is not what I want:
<asp:Repeater id="SearchResul tsRepeater" runat="server">
<ItemTemplate >
<uc:SearchResul t ID="SearchResul t"
ResultObject="< %#Container.Dat aItem%>" runat="server" />
<ButtonsTemplat e>
</ButtonsTemplate >
</uc:SearchResult >
<uc:ViewButto n ID="ViewButton "
ListingReferenc e='<%#Eval("Lis tingReference") %>' runat="server" />
</ItemTemplate>
</asp:Repeater>
I have also tried accessing <uc:ViewButtonp rogrammatically but I don't
know where to find the control:
Protected Sub SearchResultsRe peater_ItemData Bound(ByVal sender As
Object, ByVal e As System.Web.UI.W ebControls.Repe aterItemEventAr gs) Handles
SearchResultsRe peater.ItemData Bound
Dim result As SearchResultObj ect = CType(e.Item.Da taItem,
SearchResultObj ect)
If result IsNot Nothing Then
Dim resultUserContr ol As SearchResult =
CType(e.Item.Fi ndControl("Sear chResult"), SearchResult)
' FOR EXAMPLE THIS WILL NOT WORK:
' Dim viewButton As ViewButton =
CType(resultUse rControl.FindCo ntrol("ViewButt on"), ViewButton)
' viewButton.List ingReference = result.ListingR eference
End If
End Sub
Does anyone know how I find the control in this example?
Thanks!