Access Control inside GridView Pager Template - ASP.NET

NullReference picture NullReference · Jan 6, 2010 · Viewed 11k times · Source

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!

Answer

sujit kumar m picture sujit kumar m · Mar 15, 2010
GridViewRow PagerRow = GridView1.BottomPagerRow;
LinkButton b = (LinkButton)PagerRow.FindControl("lnkbtnPrevious"));