Something like:
void doSomething(Control c)
{
GridView g = c as GridView;
if (g!=null)
{
g.ShowFooter=false;
}
foreach(Control c2 in c.Controls)
{
doSomething(c2);
}
}
Note that I haven't compiled the above. The idea is that you recurse through all of the controls in a certain container (Your page should do nicely), find the GridViews, do something with the gridview (set Showfooter to false, for instance), then recurse through that control's Controls array.
Side note:Someone pointed out that they didn't understand the significance of
GridView g = c as GridView;
Unlike a regular typecase
GridView g = (GridView)c;
the "as" keyword will return null if the cast isn't valid - ie, the control isn't a GridView.
Edit:
Another (very readable) way to check the type:
if (c is GridView) g = c as GridView;