使用Xslt对Xml进行排序,并通过下拉列表更改排序列 [英] Sorting Xml with Xslt and changing sort column with a dropdown

查看:111
本文介绍了使用Xslt对Xml进行排序,并通过下拉列表更改排序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将xml加载到我的项目中,并使用xmltransform类来应用Xslt,以便它可以按特定列对文档进行排序(同时也使用Xpath).我需要能够通过更改Dropdownlist将页面上的排序更改为不同的列.

我尝试了各种不同的方法,但是都没有成功---有人有任何想法吗?

I have loaded a xml into my project and used xmltransform class to apply the Xslt so that it would sort the document by a particular column (while also using Xpath). I need to be able to change the sorting on the page to different columns by changing a Dropdownlist.

I have tried various different ways, but with no success --- Does anyone have any Ideas?

推荐答案

为此,您需要使用参数和将Dropdownlist值传递给XSL.根据您在XSL中收到的参数值,应用xsl:sort语句.大约需要执行以下操作

C#代码
For this you need to pass Dropdownlist value to XSL using parameter and based on param value which you have received in XSL apply xsl:sort statement. Roughly you need to do following

C# CODE
XslCompiledTransform tras = new XslCompiledTransform();
XsltArgumentList argList = new XsltArgumentList();
argList.AddParam("sortfield", "", "dd value");
tras.Transform("XMLfile", argList, sw);



XSL标头



XSL Header

<xsl:output method="html" indent="yes"/>
<xsl:param name="sortfield"></xsl:param>


这篇关于使用Xslt对Xml进行排序,并通过下拉列表更改排序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆