Specified argument was out of range

Posted by Snvrk1985 under ASP.NET on 6/29/2012 | Points: 10 | Views : 922 | Status : [Member] | Replies : 0
i am using list view. In data pager i have written _PreRender event. under it i have written code as

protected void Pagerindex_PreRender(object sender, EventArgs e)
{
int CurrentPage = 0;
Int32.TryParse(Request.QueryString["page"], out CurrentPage);
CurrentPage = CurrentPage.Equals(0) ? 1 : CurrentPage;

Button PreviousLink = Pagerindex.Controls[-1].Controls[-1] as Button;
Button NextLink = Pagerindex.Controls[0].Controls[2] as Button;
if (PreviousLink != null)
{
if (CurrentPage.Equals(1))
{
PreviousLink.Visible = false;
}
else if (CurrentPage > 1)
{
PreviousLink.Visible = true;
}
}
if (NextLink != null)
{
if ((CurrentPage * Pagerindex.PageSize) >= Pagerindex.TotalRowCount)
{
NextLink.Visible = false;
}
else
{
NextLink.Visible = true;
}
}
}

i am gettin error at

Button PreviousLink=Pagerindex.Controls[0].Controls[0] as Button;




Responses

(No response found.)

Login to post response