gridview分页情况分析
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { string sqlstring = "Data Source=IP;Initial Catalog=DATABASENAME;Persist Security Info=True;User ID=sa;PassWord=PASSWORD"; string sqlconn = sqlstring; SqlConnection conn = new SqlConnection(sqlconn); conn.Open(); string mysql = "select ID,COL1,COL2,COL3 from TABLE where TESTDATE BETWEEN '" + this.TextBox1.Text + "' and '" + this.TextBox2.Text + "'"; DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(mysql, conn); sda.Fill(ds); GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); conn.Close(); }