Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom DataBinding

Custom DataBinding

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netvisual-studiowpf
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jason Vetter
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups