Data View绑定Web Service返回的数据集, 显示父表, 同时以父表当前记录关联字估为条件, 嵌套显示子表
l 数据结构(以下例子以Sql Server 2000的Northwind示例数据库作例子):
l 样例Web Service:
如有: http://localhost/AspNetSample/Service1.asmx Web Services, 其中关键代码如:
[WebMethod]
public DataSet GetDataSource(string TableName)
{
DataSet ds = new DataSet("DataSetTables");
DataTable dt = new DataTable();
DataTable dtCus = new DataTable();
//sql
dt = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, "select top 100 * from Orders").Tables[0];
dt.TableName = TableName;
dtCus = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, "select top 100 * from Customers").Tables[0];
dtCus.TableName = "Customers";
ds.Tables.Add(dt.Copy());
ds.Tables.Add(dtCus.Copy());
return ds;
}
|
l 利用FrontPage 2003添加Data Source Catalog:
1. 打开Task Pane. 下拉菜单View -> Task Pane或Shortcut key Ctrl+F1 , 在Task Pane选择Data Source Catalog, 展开XML Web Services并点击Add to Catalog…
2. 在弹出的Data Source Properties窗口, 填General页内容, 给当前数据源起个名字, 例如: GetDataSource; 填Source页内容, Service Description Location为http://localhost/AspNetSample/Service1.asmx?WSDL, OK后就Connect Now! 如果Web Services设置正确, 则在Connection Info里会显示相关的Service Name, Operation 等, 我们现在在Operation选GetDataSource, 设置一下GetDataSource的接口参数; 最后要设置的是Login页的Login方法. 完成后就OK, XML Web Services下就会出现GetDataSource的图标
3. 将GetDataSource拖到页面的一个Web Part Zone内
4. 自定义Data View.
4.1. 插入一列, 并将光标置于新增列的单元格内. 再转换到Data View的Data View Details面板, 并选中Customers节点, 再Insert Subview
4.2. 设置关联关系. 此时Customers的记录会在显示Orders记录的Data View的那个新增的列内全部显示出来, 还未会根据CustomerID显示关联的Customer记录
所以现在要通过修改Data View 的XSL来实现关联过滤.
分析:
点选Data View GetDataSource, 切换到Code 视图, 找到关键的 XSL 语句, 如:
由此可以看出子表Customers是定义成一个xsl:template name=”dvt_2” 的, 我可以将CustomerID作为xsl:param传递到xsl:template里作为过滤条件
1) 添加xsl:param
修改<call-template name="dvt_2"></call-template>为如下:
<call-template name="dvt_2"></call-template>
<xsl:></xsl:> with-param name="CustomerID" select="CustomerID"/>
查找dvt_2 template定义:
<template name="dvt_2"></template>
<variable name="StyleName">Table</variable>
添加xsl:param:
<template name="dvt_2"></template>
<variable name="StyleName">Table</variable>
2) 应用xsl:param并实现过滤
将<template name="dvt_2"></template>
<variable name="StyleName">Table</variable>
<variable name="Rows" select="../Customers"></variable>
修改成:
<template name="dvt_2"></template>
<variable name="StyleName">Table</variable>
<variable name="Rows" select="../Customers[normalize-space(CustomerID) = $CustomerID]"></variable>
现在全部步骤完成了, 可以在IE浏览效果:
相关推荐
C#使用DataBinding、DataView进行数据绑定一些实例
数据视图 应用程序文档目录的文件浏览器。 可以上传文件和目录到服务器。 用法 在路由器中: import 'package:dataview/dataview.dart' ; final routes = { // ... '/dataview' : ( BuildContext context) => ...
Dataview Spark.io Automator 该项目为 Dataview 提供了一个 Spark IoT Automator。 部署既可以通过向自动化器提供 API 密钥和设备 ID 来完成,也可以只提供一个 API 密钥 (TODO)。 仍在考虑允许 dataview 处理 ...
//得到后台的数据 var proxy = new Ext.data.HttpProxy({ url:showUrl, timeout:3600000 }); //分页参数 findParams ={start:0,limit:limit}; // reader 如何解析数据 var reader = new Ext....
内容索引:C#源码,数据库应用,数据绑定 C#进行数据绑定并显示的一些实例,主要面向初级的一些实例,像如何使用DataBinding、DataView显示数据等,测试数据是ACCESS,虽然很简单,但这却是学习C#数据库编程的基础东西...
将DataView中的数据导入Excel中
主要是对dataview使用详解 具体事例 具体分析 有不懂的 可以联系我
Dataview转换成Datatable
创建和使用 DataView:描述如何创建 DataTable 中数据的动态视图,这些视图通常用于数据绑定应用程序。 创建 DataView:描述如何为 DataTable 创建 DataView。 使用 DataView 对数据排序和筛选:描述如何设置 ...
将以下方法添加到DataView: var dataview = new DataView ( ... ) ; dataview . getString ( byteOffset , optional byteLength , optional encoding ) dataview . getStringData ( byteOffset , optional ...
dataview用法dataview用法dataview用法
dataView详解dataView详解
DataTable,DataView和DataGrid用法教程:DataTable,DataView和DataGrid中一些容易混淆的概念,详细讲解了它的区别和用法。
任何数据集都可以通过dataview构造函数转换为dataview,通过dataview.full检索,通过dataview.insert添加。 后一个操作保留现有的键查找。 动机: 关系数据库的 ETL 工具可更新的视图(各种) 一个“精简版”数据库...
C#中DataView的应用
可能大家都知道dataview这个名词的概念,但也许不是很多人可以说清楚在.net架构中它的应用范围和程度。
[C#],DataView,C#教程
DATAVIEW使用,word文档格式, asp.net的C#使用,sort,filter
把DataView转换成DataTable
详解DataView用法 DataTable DataSet