在GridView的Pager是用Table組成的,這裡是做個簡單的將 "..." 改成前五頁後五頁。
else if(e.Row.RowType == DataControlRowType.Pager) { //修改page ...的樣式 TableRow pageTR = (TableRow)e.Row.Controls[0].Controls[0].Controls[0]; for(int x = 0; x< pageTR.Controls.Count; x++) { TableCell pageTD = (TableCell)pageTR.Controls[x]; for(int y = 0 ; y<pageTD.Controls.Count; y++) { if(pageTD.Controls[y] is LinkButton) { LinkButton lb = (LinkButton)pageTD.Controls[y]; if(lb.Text == "..." && x == 1) { lb.Text = "前5頁"; } else if(lb.Text =="...") { lb.Text = "後5頁"; } } } } }