Hi friends,

I am facing this problem while adding a panel to another panel. Please give me the solution. I have put my code below.

Dim pan As Panel = DirectCast(UserControlTest1.FindControl("Pan_ItemBind"), Panel)
                pan.Controls.Add(Panel1)

Thanks in advence...

Recommended Answers

All 4 Replies

Hi friends,

I am facing this problem while adding a panel to another panel. Please give me the solution. I have put my code below.

Dim pan As Panel = DirectCast(UserControlTest1.FindControl("Pan_ItemBind"), Panel)
                pan.Controls.Add(Panel1)

Thanks in advence...

hey what is UserControlTest1 ? can you please explain in detail ?

hey what is UserControlTest1 ? can you please explain in detail ?

hey the usercontroltest1 having a radgrid and three buttons. Am using this control in my page.

Okay...not sure... but this exception occurs only if there is too many nested method calls.. Also just make sure there is "Pan_ItemBind" exist in your usercontroltest1 ...

Hi friends,

I am facing this problem while adding a panel to another panel. Please give me the solution. I have put my code below.

Dim pan As Panel = DirectCast(UserControlTest1.FindControl("Pan_ItemBind"), Panel)
                pan.Controls.Add(Panel1)

Thanks in advence...

The way we would do this in C# is a s follows.

Panel childPanel = new Panel();
            parentPanel.Controls.Add(childPanel);

            /* Let's see if the parent panel has our new panel */
            if (parentPanel.HasControls())
            {
                foreach (Control ctl in parentPanel.Controls)
                {
                    if (ctl.GetType() == typeof(System.Web.UI.WebControls.Panel))
                    {

                    }

                }
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.