You need to determine which of the three lines of code that you provided, throws the exception. This can easily done using debugger.
FindControl
method searches only immediate children controls. You can write a recursive version of it to search deeper.
)
public Control FindControlDeep(Control parent, string id)
{
Control result = parent.FindControl(id);
if (result == null)
{
for (int iter = 0; iter < parent.Controls.Count; iter++)
{
result = FindControlDeep(parent.Controls[iter], id);
if (result != null)
break;
}
}
return result;
}