搜索结果能分页不能翻页
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack)
{
this.yunxing();
for (int i = 1; i < GridView1.PageCount; i++)
{
DropDownList1.Items.Add(i.ToString());
}
}
}
public void yunxing()
{
string b = Session["guanjian1"].ToString();
string a1 = Session["leixing1"].ToString();
if (b == "" && a1 == "----全部----")
{
this.guanjiankong();
}
else
{
this.guanjiankongleibian();
}
if (b != "" && a1 == "----全部----")
{
this.guanjianchaquanbu();
}
if (b != "" && a1 != "----全部----")
{
this.guanjiancha();
}
}
public void guanjiankong()
{
string a = Session["leixing1"].ToString();
string ybs = Session["guanjian1"].ToString();
DataSet news = DB.newsss("select * from newsarticle order by news_Dateer desc", ybs);
this.GridView1.DataSource = news.Tables[0];
this.GridView1.DataKeyNames=new string[] { "ID" };
this.GridView1.DataBind();
}
public void guanjiankongleibian()
{
string ybs = Session["guanjian1"].ToString();
string a2 = Session["leixing1"].ToString();
DataSet news = DB.newsss("select * from newsarticle where news_Categr='" + a2 + "'order by news_Dateer desc", ybs);
this.GridView1.DataSource = news.Tables[0];
this.GridView1.DataKeyNames = new string[] { "ID" };
this.GridView1.DataBind();
}
public void guanjianchaquanbu()
{
string ybs = Session["guanjian1"].ToString();
string b1 = Session["guanjian1"].ToString();
DataSet cha = DB.newsss("select * from newsarticle where news_Dateer like '%" + b1 + "%' or news_Author like '%" + b1 + "%' or news_Titler like '%" + b1 + "%' or news_Contnt like '%" + b1 + "%' or news_Resume like'%" + b1 + "%'order by news_Dateer desc", ybs);
this.GridView1.DataSource = cha.Tables[0];
this.GridView1.DataKeyNames = new string[] { "ID" };
this.GridView1.DataBind();
if (DB.guanjianfan(b1) == false)
{
string wucx = "wucx";
Session["wucx"]=wucx;
Response.Redirect("news.aspx");
}
} public void guanjiancha()
{
string ybs = Session["guanjian1"].ToString();
string a1 = Session["leixing1"].ToString();
string b2 = Session["guanjian1"].ToString();
DataSet cha = DB.newsss("select * from newsarticle where news_Categr='" + a1 + "' and news_Dateer like '%" + b2 + "%' or news_Author like '%" + b2 + "%' or news_Titler like '%" + b2 + "%' or news_Contnt like '%" + b2 + "%' or news_Resume like'%" + b2 + "%'order by news_Dateer desc", ybs);
this.GridView1.DataSource = cha.Tables[0];
this.GridView1.DataKeyNames = new string[] { "ID" };
this.GridView1.DataBind();
if (DB.guanjianfan(b2) == false)
{
string wucx = "wucx";
Session["wucx"] = wucx;
Response.Redirect("news.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.PageIndex = 0;
this.yunxing();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
GridView1.PageIndex = Convert.ToInt32(DropDownList1.SelectedItem.Text);
this.yunxing();
}
protected void Button2_Click(object sender, EventArgs e)
{
if (GridView1.PageIndex == 0)
{
Response.Write("<script language='javascript'>window.alert('这已经是第一页了!');</script>");
}
else
{
GridView1.PageIndex -=1;
this.yunxing();
}
}
protected void Button4_Click(object sender, EventArgs e)
{
GridView1.PageIndex = GridView1.PageCount;
this.yunxing();
}
protected void Button3_Click(object sender, EventArgs e)
{
int count = this.GridView1.PageCount - 1;
if (GridView1.PageIndex == count)
{
Response.Write("<script language='javascript'>window.alert('这已经是最后页了!');</script>");
}
else
{
GridView1.PageIndex += 1;
this.yunxing();
}
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id = this.GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
Response.Redirect("newstext.aspx?id=" + id + "");
}
}
每当我使用关键字查询全部时,下一页就没法用了。能查到结果,也分页了就是不能用。
其他没问题 关键字查分类。查询整个分类。。都没问题 这有这个关键字查询全部!
高手帮帮忙!
红色为关键字查询全部`