参照如下代码改下html样式就好 ,不明白的留言我
protected void grdvSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
//this.grdvSearchResult.PageIndex = e.NewPageIndex;
////this.DataBind();
DataTable aaa = new DataTable();
aaa = (DataTable)ViewState["TableForAllSelect"];
grdvSearchResult.DataSource = aaa;
grdvSearchResult.DataBind();
grdvSearchResult.Visible = true;
GridView theGrid = sender as GridView; // refer to the GridView
int newPageIndex = 0;
if (-2 == e.NewPageIndex)
{ // when click the "GO" Button
TextBox txtNewPageIndex = null;
//GridViewRow pagerRow = theGrid.Controls[0].Controls[theGrid.Controls[0].Controls.Count - 1] as GridViewRow; // refer to PagerTemplate
GridViewRow pagerRow = theGrid.BottomPagerRow; //GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow
//updated at 2006年6月21日3:15:33
if (null != pagerRow)
{
txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox; // refer to the TextBox with the NewPageIndex value
}
if (null != txtNewPageIndex)
{
newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex
}
}
else
{ // when click the first, last, previous and next Button
newPageIndex = e.NewPageIndex;
}
// check to prevent form the NewPageIndex out of the range
newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
// specify the NewPageIndex
theGrid.PageIndex = newPageIndex;
}