62,271
社区成员
发帖
与我相关
我的任务
分享
const string vsKey = "searchCriteria";
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
ViewState[vsKey]=Request.QueryString["SearchFor"];
DataBinder(Request.QueryString["SearchFor"]);
}
}
private void DataBinder(string strContext)
{
DataSet dscount = BLL.UserInfoBLL.GetUserCount(strContext);
this.AspNetPager.RecordCount = int.Parse(dscount.Tables[0].Rows[0][0].ToString());
int startIndex = AspNetPager.CurrentPageIndex;
DataView dv = BLL.UserInfoBLL.GetUserCountPage(AspNetPager.PageSize, startIndex, strContext);
PagedDataSource pgs = new PagedDataSource();
pgs.DataSource = dv;
pgs.AllowPaging = true;
pgs.CurrentPageIndex = AspNetPager.CurrentPageIndex - 1;
pgs.PageSize = AspNetPager.PageSize;
this.Repeater.DataSource = pgs;
this.Repeater.DataBind();
}
protected void AspNetPager_PageChanged(object src, EventArgs e)
{
DataBinder((string)ViewState[vsKey]);
}
protected void btnSelect_Click(object sender, EventArgs e)
{
string s = txtSelect.Text.Trim();
Response.Redirect(Request.Path+"?SearchFor="+HttpUtility.UrlEncode(s),true);
}
AspNetPager1.PageSize = PageSize;
AspNetPager1.RecordCount = recordCount;
AspNetPager1.UrlPaging = true;
AspNetPager1.EnableUrlRewriting = true;
AspNetPager1.UrlRewritePattern = "Itemlist.aspx?pageIndex={0}&key=" + txtKey.Value+
"&ClassId=" + HidClassId.Value +
"&second=" + Hidsecond.Value +
"&AdminId=" + selAdminId.SelectedValue +
"&Shelf=" + ddlShelf.SelectedValue +
"&isend=" + Hidfiled.Value + "";
AspNetPager1.ShowPageIndexBox = Wuqi.Webdiyer.ShowPageIndexBox.Always;
AspNetPager1.PageIndexBoxType = Wuqi.Webdiyer.PageIndexBoxType.TextBox;
<div>
<asp:GridView ID="gdvData" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
Width="100%">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<webdiyer:aspnetpager id="AspNetPager1" runat="server" PageSize="5" AlwaysShow="True" OnPageChanged="AspNetPager1_PageChanged" ShowCustomInfoSection="Left" CustomInfoSectionWidth="40%" ShowPageIndexBox="always" PageIndexBoxType="TextBox"
CustomInfoHTML="第<font color='red'><b>%currentPageIndex%</b></font>页,共%PageCount%页" Width="100%"></webdiyer:aspnetpager>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
AspNetPager1.RecordCount = DBHelper.GetCount();//得到数据的总数
this.gdvDataBind();//绑定
}
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
this.gdvDataBind();
}
protected void gdvDataBind()
{
this.gdvData.DataSource = DBHelper.GetKbhelpQuestion(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex,0,0,0,0,"","","ID");//GetKbhelpQuestion方法里面用的是分页存储过程
this.gdvData.DataBind();
}