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. Nested user controls

Nested user controls

Scheduled Pinned Locked Moved ASP.NET
questionwinformscollaborationhelp
2 Posts 2 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.
  • D Offline
    D Offline
    dabs
    wrote on last edited by
    #1

    Hi, I have a user control. It should display a list of employees in a department, but in a nested way. It is currently defined like this: - It contains a single div. - Inside this div there are three controls: - A HyperLink control (showing the name of the department) - A GridView control (listing all employees within this department) - A Repeater control (which should display all sub-departments). The repeater should actually contain a copy of the user control itself!, since it is really displaying the exact same information, only for subdepartments - and there could be an (theoretically) infinite amount of nested subdepartments. Now, obviously a user control cannot directly contain a control which is an instance of itself. However, I've managed to bypass that problem by letting the repeater contain a single PlaceHolder, and then use LoadControl to load any number of the UC. This works correctly and all the data is displayed - but in the same gridview: the gridview defined in the first UC which is loaded with LoadControl. All the others are empty. It appears that when I call e.Item.FindControl during the ItemDataBound event for the repeater, it always seems to give me the same control. Has anyone had any similar problem - or what is more important - a solution? Regards, Daníel


    Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

    I 1 Reply Last reply
    0
    • D dabs

      Hi, I have a user control. It should display a list of employees in a department, but in a nested way. It is currently defined like this: - It contains a single div. - Inside this div there are three controls: - A HyperLink control (showing the name of the department) - A GridView control (listing all employees within this department) - A Repeater control (which should display all sub-departments). The repeater should actually contain a copy of the user control itself!, since it is really displaying the exact same information, only for subdepartments - and there could be an (theoretically) infinite amount of nested subdepartments. Now, obviously a user control cannot directly contain a control which is an instance of itself. However, I've managed to bypass that problem by letting the repeater contain a single PlaceHolder, and then use LoadControl to load any number of the UC. This works correctly and all the data is displayed - but in the same gridview: the gridview defined in the first UC which is loaded with LoadControl. All the others are empty. It appears that when I call e.Item.FindControl during the ItemDataBound event for the repeater, it always seems to give me the same control. Has anyone had any similar problem - or what is more important - a solution? Regards, Daníel


      Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

      I Offline
      I Offline
      InsDev
      wrote on last edited by
      #2

      Obviously it will give the same control. but u can bind different data as u like.it can have different value of the same control in gridview. Devjit Das.

      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