当第一次查出的结果有多页时,再输入另一查询条件时,不足一页就会提示:
无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount ! ( 提交是同一页中)private void check_Click(object sender, System.EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
SqlConnection con = new SqlConnection("server=itsigt;uid=sa;pwd=123;database=phone");
SqlDataAdapter com = new SqlDataAdapter("select * from phonemain where users ='"+ X.Text +"',con);
DataSet ds = new DataSet();
com.Fill(ds, "phonemain");
DataGrid.DataSource = ds.Tables["phonemain"].DefaultView;
DataGrid.DataBind();
} protected void DataGrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid.SelectedIndex =-1;
MoreInfo.Text="您在使用分页功能!";
DataGrid.CurrentPageIndex =e.NewPageIndex;
BindGrid();
}
这个错误处理怎么来写? 大家不清楚我的意思吗?
无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount ! ( 提交是同一页中)private void check_Click(object sender, System.EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
SqlConnection con = new SqlConnection("server=itsigt;uid=sa;pwd=123;database=phone");
SqlDataAdapter com = new SqlDataAdapter("select * from phonemain where users ='"+ X.Text +"',con);
DataSet ds = new DataSet();
com.Fill(ds, "phonemain");
DataGrid.DataSource = ds.Tables["phonemain"].DefaultView;
DataGrid.DataBind();
} protected void DataGrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid.SelectedIndex =-1;
MoreInfo.Text="您在使用分页功能!";
DataGrid.CurrentPageIndex =e.NewPageIndex;
BindGrid();
}
这个错误处理怎么来写? 大家不清楚我的意思吗?
try
{
DATAGRID.DATABIND();
}
CATCH
{
DATAGRID.CURRENTPAGEINDEX=0;}
try
{
DATAGRID.DATABIND();
}
CATCH
{
DATAGRID.CURRENTPAGEINDEX=0;
DATAGRID.DATABIND();
}
我的问题就是这么解决的