首页 新闻 搜索 专区 学院

GridView分页问题

0
悬赏园豆:10 [已关闭问题] 关闭于 2008-11-19 08:58

这是点击按钮搜索的结果是3页 而我想查结果的第二页,可是却显示

代码:    protected void Page_Load(object sender, EventArgs e)
    {
            string cmdtxt2 = "SELECT * FROM tb_08";
            this.GridView1.DataSource = abc.GetData(cmdtxt2, "tb_08");
            this.GridView1.DataBind();
      
    }
   protected void GridView1_PageIndexChanging(object sender,  GridViewPageEventArgs e)
   {

       string cmdtxt2 = "SELECT * FROM tb_08";
       this.GridView1.DataSource = abc.GetData(cmdtxt2, "tb_08");
       this.GridView1.PageIndex = e.NewPageIndex;
       this.GridView1.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string cmdtxt2 = "SELECT * FROM tb_08 WHERE 统招否='"+this.TextBox1.Text.Trim()+"'";
        this.GridView1.DataSource =abc.GetData(cmdtxt2,"tb_08");
        this.GridView1.DataBind();
    }

子夜星辰的主页 子夜星辰 | 小虾三级 | 园豆:1613
提问于:2008-11-18 16:15
< >
分享
所有回答(3)
0

   protected void GridView1_PageIndexChanging(object sender,,GridViewPageEventArgs e)
   {  

      this.GridView1.PageIndex = e.NewPageIndex;

    string cmdtxt2 = "SELECT * FROM tb_08 WHERE 统招否='"+this.TextBox1.Text.Trim()+"'";

     this.GridView1.DataSource = abc.GetData(cmdtxt2, "tb_08");

       this.GridView1.DataBind();
    }

West | 园豆:1095 (小虾三级) | 2008-11-18 16:22
0

劝一句,用 ObjectDataSource,或许你的这些问题都会避免:)

Class abcProxy{

     public static IDataReader GetDatas(string filter){

                return abc.GetData("SELECT ...", "");

     }

}

陛下 | 园豆:3938 (老鸟四级) | 2008-11-18 16:40
0

下载个免费开源分页控件 AspNetPager7.2版发布。不错

零度吹风 | 园豆:0 (初学一级) | 2008-11-18 20:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册