Reputation: 1101
On my page I have the following Image control.
<asp:Image ID="Image1" ImageUrl="~/images/icons/returnarrow.gif" runat="server" />
Then on Page_Load I am doing the following.
Image1.Controls.AddAt(1, new LiteralControl("ChildControl2"));
So what this should do (theoretically) is add a new LiteralControl next to the image. But it doesn't. However, If I change the index to 0 and the Image to a GridView control it works.
What am I doing wrong?
Upvotes: 0
Views: 1223
Reputation: 46047
You should be trying to embed another control in an image. Use a PlaceHolder as the parent container, and add the Image and Literal to the PlaceHolder.
Upvotes: 1
Reputation: 6802
I don't think so Image1.Controls.AddAt
will add any control next to Image control because Image1.Controls
is a collection of child controls of Image1
, may be this.Controls.AddAt
will work
Upvotes: 1