前台页面 <asp:datagrid OnItemCreated="ItemCreaged"
protected void ItemCreaged(object sender, DataGridItemEventArgs e) { ListItemType type = e.Item.ItemType;//ListItemType是枚举,表示可以包含在列表控件中的不同项 if (type == ListItemType.Pager) { TableCell pager = (TableCell)e.Item.Controls[0]; for (int i = 0; i < pager.Controls.Count; i += 2) { object o = pager.Controls[i]; if (o is LinkButton) { LinkButton h = (LinkButton)o; h.Text = "[" + h.Text + "]"; } else { Label l = (Label)o; l.Text = "第" + l.Text + "页"; } } } }