I am adding controls dynamically to Plac开发者_C百科eHolder 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
If you want to find controls of master page then you can find like :
Label l = Master.FindControl("label1") as Label;
And in your case for finding control from contentplaceholder you can find control like :
TextBox TB=
Master.FindControl("ContentPlaceHolder1").FindControl("textbox1") as
TextBox;
I found gridview with this method:
GridView gv =(GridView)Master.FindControl("ContentPlaceHolder1").FindControl("gvRD");
If you are adding controls dynamically and you are trying to find the control after postback you will not find them.
精彩评论