第
共/
protectedvoidgrdvSearchResult_PageIndexChanging(objectsender,GridViewPageEventArgse)
{
//this.grdvSearchResult.PageIndex=e.NewPageIndex;
////this.DataBind();
DataTableaaa=newDataTable();
aaa=(DataTable)ViewState["TableForAllSelect"];
grdvSearchResult.DataSource=aaa;
grdvSearchResult.DataBind();
grdvSearchResult.Visible=true;
GridViewtheGrid=senderasGridView;//refertotheGridView
intnewPageIndex=0;
if(-2==e.NewPageIndex)
{//whenclickthe"GO"Button
TextBoxtxtNewPageIndex=null;
//GridViewRowpagerRow=theGrid.Controls[0].Controls[theGrid.Controls[0].Controls.Count-1]asGridViewRow;//refertoPagerTemplate
GridViewRowpagerRow=theGrid.BottomPagerRow;//GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow或者TopPagerRow,当然还增加了HeaderRow和FooterRow
//updatedat2006年6月21日3:15:33
if(null!=pagerRow)
{
txtNewPageIndex=pagerRow.FindControl("txtNewPageIndex")asTextBox;//refertotheTextBoxwiththeNewPageIndexvalue
}
if(null!=txtNewPageIndex)
{
newPageIndex=int.Parse(txtNewPageIndex.Text)-1;//gettheNewPageIndex
}
}
else
{//whenclickthefirst,last,previousandnextButton
newPageIndex=e.NewPageIndex;
}
//checktopreventformtheNewPageIndexoutoftherange
newPageIndex=newPageIndex<0?0:newPageIndex;
newPageIndex=newPageIndex>=theGrid.PageCount?theGrid.PageCount-1:newPageIndex;
//specifytheNewPageIndex
theGrid.PageIndex=newPageIndex;
}