views:

105

answers:

1

I am adding controls dynamically to PlaceHolder which within ContentPlaceHolder

var t = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
var t1 = (PlaceHolder)mpContentPlaceHolder.FindControl("PlaceHolderName");

var t2 = (DropDownList)t1.FindControl("ControlID");

It looks like I am missing something because t2 is always null

A: 

If you are adding controls dynamically and you are trying to find the control after postback you will not find them.

Vinay B R
im doing it on button click and it works if Im not using ContentPlaceHolder just PlaceHolder. but I have a content pages so I need to use it
MasterPiece
what is mpContentPlaceHolder in your code. you have assigned ContentPlaceHlder1 to variable t. i tried something like this 'Master.FindControl("ContentPlaceHolder1").FindControl("PlaceHolderName").FindControl("ControlID")' and it worked without any problems.
Vinay B R