private void Submit1_ServerClick(object sender, System.EventArgs e)
{
string str="select * from Book";
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
if(TextBox1.Text != null)
{
str=str+" where bookname like '%"+TextBox1.Text+"%'";
}
SqlCommand comm = new SqlCommand(str,conn);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
Label1.Text = DataGrid1.PageCount.ToString();
da.Fill(ds ,"Book");
DataGrid1.DataSource =ds;
DataGrid1.DataBind();
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex ;
DataGrid1.DataBind();
}
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
DataGrid1.CurrentPageIndex=0;
}
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
为什么在多次查询后,点下一页时出现CURENTPAGEINDEX必须大于0小于PAGECOUT的错误