public void bindData(int pageIn, string selectWhere) { BLL.eventsTb bllevent = new BLL.eventsTb(); List<Model.eventsTb> modevent = bllevent.GetModelList(selectWhere); //BLL.noveltyTb bllAdmin = new BLL.noveltyTb(); //List<Model.noveltyTb> admins = bllAdmin.GetModelList(selectWhere); PagedDataSource pds = new PagedDataSource(); pds.DataSource = modevent; pds.PageSize = 8; pds.AllowPaging = true; pds.CurrentPageIndex = pageIn; this.gvSuperAdminSeeInfo.DataSource = pds; this.gvSuperAdminSeeInfo.DataBind(); int pageCount = pds.PageCount; StringBuilder html = new StringBuilder(""); html.Append("<a class='pageA pageStart' href='adminSeeEvents.aspx?pageInd=0'>首页</a>"); for (int i = 0; i < pageCount; i++) { html.Append("<a class='pageA pageNum pageA" + (i + 1).ToString() + "' href='adminSeeEvents.aspx?pageInd=" + i.ToString() + "'>" + (i + 1).ToString() + "</a>"); } html.Append("<a class='pageA pageStart' href='adminSeeEvents.aspx?pageInd=" + (pageCount - 1).ToString() + "'>尾页</a>"); this.dgvpage.InnerHtml = html.ToString(); ScriptManager.RegisterStartupScript(searchBtn, this.GetType(), "clickPage", "clickPage(" + (pageIn + 1).ToString() + ");", true); }
protected void search_Click(object sender, EventArgs e) { //Response.Write("<Script type='text/javascript'>alert( this.dgvpage.InnerHtml);</Script>"); string searchT = this.searchText.Text; if (searchT == "") { ScriptManager.RegisterStartupScript(searchBtn, this.GetType(), "showErrorAlert", "showErrorAlert('请输入关键字!');", true); return; } try { BLL.eventsTb bllevents = new BLL.eventsTb(); List<Model.eventsTb> modevents = bllevents.GetModelList("ID like '%" + searchT + "%' and operatorID!=1 and operateContent like '用户%'"); if (modevents.Count == 0) { ScriptManager.RegisterStartupScript(searchBtn, this.GetType(), "showNoticeAlert", "showNoticeAlert('没有您要找的新鲜事!');", true); return; } bindData(0, "ID like '%" + searchT + "%' and operatorID!=1 and operateContent like '用户%'"); } catch (Exception) { ScriptManager.RegisterStartupScript(searchBtn, this.GetType(), "showErrorAlert", "showErrorAlert('发生错误,请重新输入关键字!');", true); } }