这是点击按钮搜索的结果是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();
}
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();
}
劝一句,用 ObjectDataSource,或许你的这些问题都会避免:)
Class abcProxy{
public static IDataReader GetDatas(string filter){
return abc.GetData("SELECT ...", "");
}
}
下载个免费开源分页控件 AspNetPager7.2版发布。不错