使用xml绑定实现分页功能

类别:.NET开发 点击:0 评论:0 推荐:

        对于分页功能,可以采用数据岛绑定的方法进行分页,当然如果数据量太巨的话,不建议使用这种方法,那样可以结合其它方法进行分页

        如下:

<HTML>
<HEAD>
<style>
table{border:1px solid black; }
td{ border:1px solid black;width:100px;}
</style>
</HEAD>
<BODY>
<XML ID="xmlParts">
<?xml version="1.0" ?>
    <parts>
        <part>
            <partnumber>1</partnumber>
            <description>Flat</description>
            <quantity>1000</quantity>
        </part>
        <part>
            <partnumber>2</partnumber>
            <description>Machine</description>
            <quantity>1000</quantity>
        </part>
        <part>
            <partnumber>3</partnumber>
            <description>Nail</description>
            <quantity>500</quantity>
        </part>
        <part>
            <partnumber>4</partnumber>
            <description>Sert</description>
            <quantity>10400</quantity>
        </part>
        <part>
            <partnumber>5</partnumber>
            <description>Magic</description>
            <quantity>5020</quantity>
        </part>
        <part>
            <partnumber>6</partnumber>
            <description>Flat</description>
            <quantity>1000</quantity>
        </part>
        <part>
            <partnumber>7</partnumber>
            <description>Machine</description>
            <quantity>1000</quantity>
        </part>
        <part>
            <partnumber>8</partnumber>
            <description>Nail</description>
            <quantity>500</quantity>
        </part>
        <part>
            <partnumber>9</partnumber>
            <description>Sert</description>
            <quantity>10400</quantity>
        </part>
        <part>
            <partnumber>10</partnumber>
            <description>Magic</description>
            <quantity>5020</quantity>
        </part>
    </parts>
</XML>
<div style="height:200px;">
<table border="0" cellpadding="2" cellspacing="0" datasrc=#xmlParts id="tb1" datapagesize="2">
    <tr>
        <td><div datafld="partnumber"></div></td>
        <td><div datafld="description"></div></td>
        <td><div datafld="quantity"></div></td>
    </tr>
</table>
</div>
<a href="javascript:go(1)">1</a>
<a href="javascript:go(2)">2</a>
<a href="javascript:go(3)">3</a>
<a href="javascript:go(4)">4</a>
<a href="javascript:go(5)">5</a>
<script language="javascript">
function go(pageNum)
{
    tb1.firstPage();
    for(var i=1; i<pageNum; i++)
        tb1.nextPage();
}
</script>
<p>
<INPUT type="button" value=" << " onClick="tb1.firstPage()">
<INPUT type="button" value=" < " onClick="tb1.previousPage()">
<INPUT type="button" value=" > " onClick="tb1.nextPage()">
<INPUT type="button" value=" >> " onClick="tb1.lastPage()">
</BODY>
</HTML>

本文地址:http://com.8s8s.com/it/it44335.htm