陈宝刚---享受生活,追逐梦想!
理想是心中的火焰,有追求的人才是幸福的人!
DataSet ds;
    SqlDataAdapter dr;
    SqlCommand com;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["shanxiConnectionString"].ConnectionString);
            com = new SqlCommand("select count(*) from Artist",con);
            con.Open();
            AspNetPager1.RecordCount=(int)com.ExecuteScalar();
       
            con.Close();
            bind();
        }
    }

    public void bind()
    {


        int count = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize;
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["shanxiConnectionString"].ConnectionString);
        dr = new SqlDataAdapter("select * from Artist", con);
        ds = new DataSet();
        dr.Fill(ds, count, AspNetPager1.PageSize, "Artist");
      
        GridView1.DataSource = ds.Tables["Artist"];
        GridView1.DataBind();
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bind();
    }

posted on 2010-04-11 12:46  追梦人RUBY  阅读(157)  评论(0编辑  收藏  举报