private void EnableOrDisableButtons()
{
//=== check the condition total no of pages is greater than zero ==============
if(TotalNumberOfPages >0){
//===== Initial setup =============
if(CurentPageNumber == 0)
{
CurentPageNumber = 1;
}
//===== Now the User is in First Page [Total page is 1] =============
if ((CurentPageNumber == 1) && ( CurentPageNumber == TotalNumberOfPages))
{
lnkFirst.Enabled = lnkPrev.Enabled = false;
}
//===== Now the User is in middle Page =============
else if (CurentPageNumber == 1 && CurentPageNumber < TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = false;
lnkNextButton.Enabled = lnkLastButton.Enabled = true;
}
//===== here also Now the User is in middle Page =============
else if (CurentPageNumber > 1 && CurentPageNumber < TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = lnkNextButton.Enabled = lnkLastButton.Enabled = true;
}
//===== Now the User is in last Page =============
else if (CurentPageNumber == TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = true;
lnkNextButton.Enabled = lnkLastButton.Enabled = false;
}
//======= Setting the page Numbers=======
this.lblPage.Text = CurentPageNumber.ToString() + " of " + TotalNumberOfPages.ToString();
}
No comments:
Post a Comment