Function FindControlEx(ByVal Parent As System.Web.UI.Control, ByVal ID As String) As System.Web.UI.Control
Dim oCtrl As System.Web.UI.Control = Nothing
Dim oChildCtrl As System.Web.UI.Control = Nothing
'先使用 FindControl 去尋找指定的子控制項
oCtrl = Parent.FindControl(ID)
'若尋找不到則往下層遞迴方式去尋找()
If oCtrl Is Nothing Then
For Each oChildCtrl In Parent.Controls
'以遞迴方式呼叫原函式
oCtrl = FindControlEx(oChildCtrl, ID)
'若有尋找到指定控制項則離開迴圈
If oCtrl IsNot Nothing Then Exit For
Next
End If
Return oCtrl
End Function
Source