我在百度里搜了一下,用System.Convert.ToInt32可以解决问题,但是不知道在下面的程序里怎么用。大家帮忙看一下
void PagerButtonClick(Object sender, EventArgs e)
{
//获得LinkButton的参数值
String arg = ((LinkButton)sender).CommandArgument;
switch (arg)
{
case ( "next "):
if (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1))
MyDataGrid.CurrentPageIndex++;
break;
case ( "prev "):
if (MyDataGrid.CurrentPageIndex > 0)
MyDataGrid.CurrentPageIndex--;
break;
case ( "last "):
MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1);
break;
default:
//本页值
MyDataGrid.CurrentPageIndex = arg.ToInt32();
break;
}
BindGrid();
}
------解决方案--------------------------------------------------------
MyDataGrid.CurrentPageIndex = int.Parse(arg);
------解决方案--------------------------------------------------------
一眼就看到这句有问题:
MyDataGrid.CurrentPageIndex = arg.ToInt32();
应该是这样:
MyDataGrid.CurrentPageIndex = Convert.ToInt43(arg);
------解决方案--------------------------------------------------------
Convert.ToInt32(arg)
------解决方案--------------------------------------------------------
//本页值
MyDataGrid.CurrentPageIndex = Convert.ToInt32(arg);
------解决方案--------------------------------------------------------