DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 15 Aug 2007 14:35:37 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    NKaufman
          2    NKaufman


Please Help! Dynamic User Controls   
In my pageload I am adding multiple instances of same User control.
They all have properties ID and ParentID.

Now I also have a button in each User control and am bubbling the
event back to main form. No problem so far.

Now in the event handler method, I get the ID of the user control that
raised the event (through the ID property of sender). I now need to go
through all the user controls on my page to see which one has parentID
matching the ID of the event raising user control.

foreach (Control1 MyCo in this.Page.Controls)
        {

            Response.Write(MyCo.GetType());
            if (MyCo.MyParentID == ParID)
                    MyCo.Visible = false;

        }

I do not see any user control in the output of response.write

Right now, the controls are loaded everytime the page is loaded.

Please help..
Date:Wed, 15 Aug 2007 14:35:37 -0700   Author:  

Re: Please Help! Dynamic User Controls   
Here is my PageLoad snippet:


       HtmlTable itemTable2 = new HtmlTable();
        itemTable2.Width = "1200";
        HtmlTableRow itemRow2 = new HtmlTableRow();
        int j = 0;

        foreach (DataRow myrow in ds.Tables["Sub"].Rows)
        {
            HtmlTableCell itemCell1 = new HtmlTableCell();
            itemCell1.Width = "200";
            Control MyControl = LoadControl("Control1.ascx");
            Control1 MyC = (Control1)MyControl;
            MyC.MyID = Convert.ToInt32(myrow["ID"]);
            MyC.MyParentID = Convert.ToInt32(myrow["ParentID"]);
            MyC.ID = "Control3" + j;
            MyC.MyDataRow = myrow;

            MyC.BubbleClick += new
EventHandler(Default3_BubbleClick);

            itemCell1.Controls.Add(MyC);
            itemRow2.Cells.Add(itemCell1);

            HtmlTableCell itemCell2 = new HtmlTableCell();
            itemCell2.Width = "20";
            itemCell2.InnerHtml=" ";
            itemRow2.Cells.Add(itemCell2);
            j++;
        }
        itemTable2.Controls.Add(itemRow2);
        Panel3.Controls.Add(itemTable2);
Date:Wed, 15 Aug 2007 15:05:07 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us