1。分页中的服务器端C#代码的查询
"tb_bri_rec":string.Format("select GB_TYPE,count(GB_TYPE) as COL_NUM FROM GL_BRICF group by GB_TYPE having GB_TYPE={0}",iid)
2。XSLT中的代码:
全局变量,要注意num是全局的,否则会出错
<xsl:variable name="state" select="/../QueryString/pagesize"/>
<xsl:variable name="pro" select="floor(/../tb_bri_rec/COL_NUM div $pagecount)-(/Toolkit/tb_bri_rec/COL_NUM)"/>
<xsl:variable name="num">
<xsl:choose>
<xsl:when test="$pro">
<xsl:if test="$pro<0">
<xsl:value-of select="floor(/../tb_bri_rec/COL_NUM div $pagecount)+1"/>
</xsl:if>
<xsl:if test="$pro=0">
<xsl:value-of select="floor(/../tb_bri_rec/COL_NUM div $pagecount)"/>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:variable>
内部样式代码:
<xsl:template match="/">
<tr>
<th>共<xsl:value-of select="$num"/>页
<xsl:call-template name="dots">
<xsl:with-param name="n" select="1"/>
</xsl:call-template>
</th>
</tr>
</xsl:template>
3。页数列表模板代码:
<xsl:template name="dots">
<xsl:param name="n"/>
<xsl:if test="$n<=$num">
<xsl:choose>
<xsl:when test="$n=$state"> //当前页
<font color="gray">[<xsl:value-of select="$n"/>]</font>
</xsl:when>
<xsl:otherwise>
<a href="javascript:repage({$n})">[<xsl:value-of select="$n"/>]</a>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="dots">
<xsl:with-param name="n" select="number($n)+1"/>
</xsl:call-template>
</xsl:if>
<script type="text/javascript" language="javascript"> //脚本将值传到后台
function repage(p){
var typeid=<xsl:value-of select="/../tb_bri_rec/GB_TYPE"/>
this.location="../...aspx?id="+typeid+"&pagesize="+p;
}
</script>
</xsl:template>