views:

53

answers:

3

Hello I am written a User Control. in the User Control, There are Header and Footer.
i want insert gridview or any Control , in Content of the User control.
for a Example:
<Menu:Menu id="1" runAt="Server">
<Asp:GridView ...> /// or any control
</Menu>

Thanks

A: 

Use a Placeholder control.

<Menu:Menu id="1" runAt="Server">
    <asp:Placeholder id="phControl" runat="server" />
</Menu>

And in your code-behind:

TextBox myText = new TextBox();
phControl.Controls.Add(myText);
Ravish
If you cannot put a control inside the usercontrol, you can't even put a placeholder there.
gius
A: 

You should use the ParseChildren attribute. Check this and this posts.

gius
+1  A: 

Have a look at this example to create your own Templated Controls:

http://msdn.microsoft.com/en-us/library/ms178657.aspx

This way you can create a WebControl that can contain templates where you place any control.

Mark Redman