I currently have a dropdown inside an ascx control. I need to "find" it from within the code behind on another ascx that is on the same page. It's value is used as a param to an ObjectDataSource on ascx #2. I am currently using this ugly piece of code. It works but I realize if the conrtol order were to change or various other things, it wouldn't be where I am expecting. Does anyone have any advice how I should properly be doing this?
if(Page is ClaimBase)
{
var p = Page as ClaimBase;
var controls = p.Controls[0].Controls[3].Controls[2].Controls[7].Controls[0];
var ddl = controls.FindControl("ddCovCert") as DropDownList;
}
Thanks and Happy New Year!!
~ck in San Diego
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…