repeater模糊查询
用Repeater模糊查询,点击查询按钮,结果能够显示。但是查出每次点击下一页按钮时,repeater却显示全部信息。怎么解决?还是让Repeater显示查询结果!!我是用三层架构做的。
代码:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;
using Model;
namespace StaffSystem
{
public partial class ModifyStaff : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
pds();
Repeater1.DataSource = pbs;
Repeater1.DataBind();
}
}
public PagedDataSource pbs;
public void pds()
{
Staff staff = new Staff();
staff.Name = this.txtName.Text.ToString();
staff.Sex = this.txtSex.Text.ToString();
DataSet ds = StaffBLL.GetDS(staff);
pbs = new PagedDataSource();
pbs.DataSource = ds.Tables[0].DefaultView;
pbs.AllowPaging = true;
pbs.PageSize = 3;
pbs.CurrentPageIndex = Convert.ToInt32(Request.QueryString["Page"]);
//this.Repeater1.DataSource = ds;
//this.Repeater1.DataBind();
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
Label labCountPage = (Label)e.Item.FindControl("labCountPage");
Label labCurrentPage = (Label)e.Item.FindControl("labCurrentPage");
HyperLink linkFirst = (HyperLink)e.Item.FindControl("linkFirst");
HyperLink linkPre = (HyperLink)e.Item.FindControl("linkPre");
HyperLink linkNext = (HyperLink)e.Item.FindControl("linkNext");
HyperLink linklast = (HyperLink)e.Item.FindControl("linklast");
linkFirst.Enabled = true;
linkPre.Enabled = true;
linkNext.Enabled = true;
linklast.Enabled = true;
int pageCount = pbs.PageCount;
int curCount = pbs.CurrentPageIndex;
if (curCount <= 0)
{
linkFirst.Enabled = false;
linkPre.Enabled = false;
linkNext.Enabled = true;
linklast.Enabled = true;
}
else
{
linkPre.NavigateUrl = "?Page=" + (curCount - 1);
}
if (curCount >= pageCount - 1)
{
linkFirst.Enabled = true;
linkPre.Enabled = true;
linkNext.Enabled = false;
linklast.Enabled = false;
}
else
{
linkNext.NavigateUrl = "?Page=" + (curCount + 1);
}
linkFirst.NavigateUrl = "?Page=0";
linklast.NavigateUrl = "?Page=" + (pageCount - 1);