I saw a post on the CSDN forum this morning about how to modify the style of ASP.net pager. Described below--
-----------------------------------------------------------------
The page navigation for the DataGrid has two modes: prev/Next and page number, and when page number mode is selected, if the pages are more than 10 pages, they are displayed.
1 2 3 4 5 6 7 8 9 10 ...
I would like to ask is: there is no better way to the back of ... Change to Chinese, for example "more"
-----------------------------------------------------------------
The problem seems to be a bit difficult at first because the paging number "..." has been encapsulated in the DataGrid, and the DataGrid does not provide the appropriate attributes to modify. So many friends would like to inherit from the DataGrid themselves to write a "personalized" datagrid, or with some third-party control to achieve, this is feasible, but greatly increased the cost of development, not to the last resort, these methods I do not think it is good.
From another perspective, the DataGrid to the front is a common <Table> element (HTML object), using the powerful features of Dhtml+javascript, can change the page on the client dynamically any elements, change a few words naturally ...
Example:
Background code--
(Add a new DataGrid on the page and set its paging to 8 data per page, page navigation with "number" and add the following code in the background Page_Load event)
private void Page_Load (object sender, System.EventArgs e)
{
DataTable table = new DataTable ();
Table. Columns.Add ("Test", typeof (String));
for (int i=0;i<100;i++)
Table. Rows.Add (New object[]{"test data _" +i});
This. DataGrid1.DataSource = table;
This. Datagrid1.databind ();
}
Front code--
(Copy the code to the page <Head></Head>)
<script language= "JavaScript" >
<!--
Window.attachevent ("onload", Handledatagrid);
function Handledatagrid ()
{
var DataGrid = document.getElementById ("DataGrid1");
var Pagecell = datagrid.rows[datagrid.rows.length-1].cells[0];
Pagecell.childnodes[pagecell.childnodes.length-1].innertext = "more";
}
-->
</script>
Note: Analysis of the DataGrid generated client code, found that "..." is actually located in the last line of <Table> in the last <a> tag, so you can use the pagecell.childnodes[ Pagecell.childnodes.length-1] Gets a reference to the tag
-------------------------------------------------------
Digression:
In fact, a lot of complex or difficult to achieve things, if we analyze from another angle, many times we can get a simple solution