为gridview创建 RowDataBound 事件,里面这样写
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
Label lb1 = (Label)e.Row.FindControl("Label1");//你放的label的ID lb1.Text = "成功了!"; }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
Label lb1 = (Label)e.Row.FindControl("Label1");//你放的label的ID lb1.Text = "成功了!"; }
{
List<GridViewRow> result=new List<GridViewRow>();
foreach(GridViewRow gvr in gv.Rows)
if(fvr.rowType==DataControlRowType.Pager)
result.Add(gvr);
return result;
}要知道,一个GridView实例中可能没有pager行,也可能不止一行。你可以根据返回的集合,来 逐行 FindControl。