+ Reply to Thread
Results 1 to 5 of 5

Thread: Declare and add Custom Controls programmatically to a panel

  1. #1
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    Declare and add Custom Controls programmatically to a panel

    hi guys

    I have 13 custom controls (.ascx) which each hold diff forms for data to be
    captured to a db.

    These forms get displayed if they have been assigned to a certain sub-category
    ie. user assigns 2 forms to sub-category, both forms then display under that sub
    and uset can capture the data.

    now the repeater to list the forms sits inside a 3rd-level repeater.
    the order of repeaters:
    Code:
    category
     - subcategory
      - specs
       - forms
    
    here's the code that populates the 'forms' repeater:
    Code:
    Dim myForms As FormsList = New FormsList
            myParams.OrderBy = "name ASC"
            myParams.FormID = hdn_formID.Value
            myForms = FormsManager.GetListByID(myParams)
    
            rpActiveSpecification.DataSource = myForms
            rpActiveSpecification.DataBind()
    
    now in my 'forms' repeater's OnItemDataBound I want to add my custom
    controls to a panel inside the repeater.

    this is what i'm not sure of, normally you would declare a control like so:
    Code:
    Dim pnl As Panel = e.item.findcontrol("pnl")
    
    but not sure how that works for a custom control?
    Shem

  2. #2
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    Do i declare it as my custom controls ascx.vb class name?

  3. #3
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    it seems as if that worked?
    i'm getting an error, but it's due to a problem in one of my controls methods..

    and it's page_load event fired, so i guess it's working?

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    It is possible and the following shows how to do what you're asking: How to: Create Instances of ASP.NET User Controls Programmatically
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  5. #5
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    I went with that example you provided in the link JMH, but i wonder
    if it would still have worked the way i was doing it?

    oh well, the example in the link looks more solid anyways, ...thanks

+ Reply to Thread

Similar Threads

  1. Custom Calendar Control
    By AOG123 in forum Access Database Samples
    Replies: 6
    Last Post: December 10th, 2008, 05:34 PM
  2. Custom Code Tip
    By Lauramc in forum SQL Server Reporting Services Help
    Replies: 0
    Last Post: August 6th, 2008, 09:31 PM
  3. what do i declare my datasource as?
    By Shem in forum .NET Development
    Replies: 3
    Last Post: August 4th, 2008, 05:13 AM
  4. Update Panel
    By Shem in forum .NET Development
    Replies: 3
    Last Post: July 10th, 2008, 05:37 AM
  5. Accessing controls in the Footer of a datalist
    By richyrich in forum .NET Development
    Replies: 6
    Last Post: May 12th, 2008, 01:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO