views:

658

answers:

3

Hi,

I am trying to access a LinkButton that is inside a PagerTemplate in a GridView.

However, I am getting a NullReferenceException and I don't know what I am doing wrong here.

I have tried the following...

((LinkButton)GridView1.BottomPagerRow.FindControl("lnkbtnPrevious"));
((LinkButton)GridView1.FindControl("lnkbtnPrevious"));

Can someone please help?

Thanks!

A: 

I am having the same issue...can anyone please help?

NullReference
+1  A: 

GridViewRow PagerRow = GridView1.BottomPagerRow; LinkButton b = (LinkButton)PagerRow.FindControl("lnkbtnPrevious"));

sujit kumar m
This solution works! Should be marked as the answer. Thanks!
Micah
A: 

First create a link button in pagertemplate for gird and give id= "LB"

work this in code in databound event of gridview

protected void grid_DataBound(object sender, EventArgs e)
{
 LinkButton lb = (LinkButton)grid.BottomPagerRow.FindControl("LB");
}

this will work

santosh