Custom DataBinding
-
I have several custom controls that I am using. These controls are part of a Web Control Library Project that can be referenced and used within other regular asp.net web projects. Among others, I have 2 custom repeaters. Here is an example of one: The Source attribute offers an intellisense dropdown. Here is what Im trying to do: From within the ItemTemplate, I want this: <*itemtemplate> <*li><*hh:product runat="server" item="FeatureText" /> <*/itemtemplate> Instead of: <*itemtemplate> <*li><%# DirectCast(Container.DataItem, WebDataModule.NameOnly).Name %> <*/itemtemplate> The Object that is being bound 'WebDataModule.NameOnly', in this case, is a simple ArrayList. I want to be able to use some of my custom controls within the ItemTemplate but by doing that I will need to have control of the binding. This is what I did next in the code behind of the repeater: 'Protected Overrides Sub OnDataBinding(ByVal e As System.EventArgs) ' 'Determine what type of control we have so we can determine what value to extract from it ' '1) Loop thru all the Controls within the Repeater to determine what type of controls we have ' Dim objControl As Control ' Dim objEnumerator As IEnumerator ' If Me.Controls.Count > 0 Then ' For Each objControl In Me.Controls ' If TypeOf objControl Is Product Then ' Select Case DirectCast(objControl, Product).Item ' Case Global.ProductPropertyEnum.FeatureText ' objEnumerator = DirectCast(objControl, Product).Page.UserData.Product.Features.GetEnumerator ' While objEnumerator.MoveNext ' Controls.Add(New LiteralControl(objEnumerator.Current.ToString)) ' End While ' End Select ' End If ' Next ' End If 'End Sub The problem is that inside of this event, I cannot get to my custom control. Me.Controls.Count always returns 0. In addition, If I debug and try and do: Me.FindControl("Id_Of_My_Custom_Control"), it does not find it and returns nothing. Now, I can access the custom control from within the OnItemCreated event, but that isnt going to help (I dont think). I cant even access the custom control from the Page.Controls collection which I found very odd. If you have ever tried to do someth