取MyDataGrid.CurrentPageIndex值的函数,老是取到的值为0
public void PagerButtonClick(object sender, EventArgs e)
{
string arg = ((LinkButton)sender).CommandArgument.ToString();
switch(arg)
{
case "next ":
if (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1))
{
MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex + 1;
}
break;
case "prev ":
if (MyDataGrid.CurrentPageIndex > 0)
{
MyDataGrid.CurrentPageIndex -= 1;
}
break;
case "last ":
MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1);
break;
default:
MyDataGrid.CurrentPageIndex = System.Convert.ToInt32(arg);
break;
}
}
这个函数每次取到的MyDataGrid.CurrentPageIndex值都是零,即使经过MyDataGrid.CurrentPageIndex+1,下次取又成零了,请高手赐教
------解决方案--------------------页面上放一个Label保存页码,取的时候读Label的TEXT,再Convert.ToInt32就行了.