public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnfirst.Enabled = false;
btnprevious.Enabled = false;
}
protected void btnnext_Click(object sender, EventArgs e)
{
int i = gridview1.PageIndex + 1;
if (i <= gridview1.PageCount)
{
gridview1.PageIndex = i;
btnlast.Enabled = true;
btnprevious.Enabled = true;
btnfirst.Enabled = true;
}
if (gridview1.PageCount-1 == gridview1.PageIndex)
{
btnnext.Enabled = false;
btnlast.Enabled = false;
}
}
protected void btnprevious_Click(object sender, EventArgs e)
{
int i = gridview1.PageCount;
if (gridview1.PageIndex > 0)
{
gridview1.PageIndex = gridview1.PageIndex - 1;
btnlast.Enabled = true ;
}
if (gridview1.PageIndex == 0)
{
btnfirst.Enabled = false;
}
if (gridview1.PageCount - 1 == gridview1.PageIndex+1)
{
btnnext.Enabled = true;
}
if (gridview1.PageIndex == 0)
{
btnprevious.Enabled = false;
}
}
protected void btnlast_Click(object sender, EventArgs e)
{
gridview1.PageIndex = gridview1.PageCount;
btnlast.Enabled = false;
btnfirst.Enabled = true;
}
protected void btnfirst_Click(object sender, EventArgs e)
{
gridview1.PageIndex = 0;
btnfirst.Enabled = false;
btnprevious.Enabled = false;
btnlast.Enabled = true;
btnnext.Enabled = true;
}
}