递归遍历页面控件
private Control returnCtrl;
/// <summary>
/// 递归遍历页面控件
/// </summary>
/// <param name="oControl"></param>
private Control LoopingControls(Control oControl)
{
foreach (Control frmCtrl in oControl.Controls)
{
if (frmCtrl is GridView)
if (((GridView)frmCtrl).ID == ControlToPaginate)
{
returnCtrl = frmCtrl; break;
}
if (frmCtrl is Repeater)
if (((Repeater)frmCtrl).ID == ControlToPaginate)
{
returnCtrl = frmCtrl; break;
}
if (frmCtrl is BaseDataList)
if (((BaseDataList)frmCtrl).ID == ControlToPaginate)
{
returnCtrl = frmCtrl; break;
}
if (frmCtrl.HasControls())
LoopingControls(frmCtrl);//递归遍历
}
return returnCtrl;
}
#endregion
/// <summary>
/// 递归遍历页面控件
/// </summary>
/// <param name="oControl"></param>
private Control LoopingControls(Control oControl)
{
foreach (Control frmCtrl in oControl.Controls)
{
if (frmCtrl is GridView)
if (((GridView)frmCtrl).ID == ControlToPaginate)
{
returnCtrl = frmCtrl; break;
}
if (frmCtrl is Repeater)
if (((Repeater)frmCtrl).ID == ControlToPaginate)
{
returnCtrl = frmCtrl; break;
}
if (frmCtrl is BaseDataList)
if (((BaseDataList)frmCtrl).ID == ControlToPaginate)
{
returnCtrl = frmCtrl; break;
}
if (frmCtrl.HasControls())
LoopingControls(frmCtrl);//递归遍历
}
return returnCtrl;
}
#endregion