jonson1126
各种问题 各种方法 各种解决 路要自己走一遍才知个中滋味

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();
    } 

 

posted on 2012-12-07 14:51  jonson1126  阅读(199)  评论(0编辑  收藏  举报