获取GridView分页模板里的控件,首先要用到下面这句:
GridViewRow row = GridView1.BottomPagerRow;
GridViewRow 有FindControl方法,这样就可以用row.FindControl("id")获取想要查找的控件了。
这里有一点要注意,使用BottomPagerRow要确保GridView数据有多页,如果只有一页,那么此时的BottomPagerRow就为null,所以row.FindControl("id")也就无从谈起了,在使用row.FindControl("id")判断下row是否为null还是很需要的,例如:
GridViewRow row = this.GridView1.BottomPagerRow;
if (row != null)
{
//你的程序
}