web| data Working with the database View Web part
Microsoft®office frontpage®2003
Author:ben
msn:benjamine65@hotmail.com
How to use DataView to invoke XML Web Services
How to display a parent-child from a table
L Design Goal:
Data View binds the dataset returned by the Web service, displays the parent table, and, in the context of the parent table's current record association word, the nested display child table
l data Structure (The following example is an example of the Northwind sample database for SQL Server 2000):
L Sample Web Service:
such as: Http://localhost/AspNetSample/Service1.asmx Web Services, where key code such as:
[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 * from Orders"). Tables[0];
dt. tablename = tablename;
Dtcus = SqlHelper.ExecuteDataset (ConnectionString, CommandType.Text, "select top * from Customers"). Tables[0];
dtcus.tablename = "Customers";
ds. Tables.add (dt. Copy ());
ds. Tables.add (Dtcus.copy ());
return DS;
}
l Add data Source Catalog with FrontPage 2003:
1. Open Task Pane. Drop-down Menu View-> task pane or shortcut key ctrl+f1, select Data Source pane in Task Catalog, expand XML Web Services and click Add to Catalog ...
2. In the pop-up Data Source Properties window, fill out the contents of the General page, give the current source name, such as: Getdatasource; Fill in the source page content, Service Description location for Http://localhost/AspNetSample/Service1.asmx?WSDL, OK after connect now! If the Web services settings are correct, the associated service Name, Operation, and so on in connection info will be displayed, and we are now choosing Getdatasource in Operation, Set the Getdatasource interface parameters; The last thing to set up is the login method for the login page. When you're done, the Getdatasource icon will appear under XML Web services
3. Drag Getdatasource to a Web Part zone in the page
4. Custom Data View.
4.1. Inserts a column and places the cursor in the cell of the new column. Switch to the Data View Details panel of Data View and select the Customers node and insert Subview
4.2. Set up association relationships. The customers record is displayed in the new column in the Data view that displays the orders record, and the associated customer record is not displayed according to CustomerID
so now it's time to implement association filtering by modifying the XSL of data View.
Analysis:
Click the Data View getdatasource, switch to the Code view, and find the key XSL statements, such as:
From this we can see that the child table customers is defined as a xsl:template name= "dvt_2", I can pass CustomerID as Xsl:param to Xsl:template as a filter condition
1) Add Xsl:param
Modify <xsl:call-template name= "Dvt_2"/> as follows:
<xsl:call-template name= "dvt_2" >
<xsl:with-param name= "CustomerID" select= CustomerID "/>"
</xsl:call-template>
lookup dvt_2 Template definition:
<xsl:template name= "dvt_2" >
<xsl:variable name= "StyleName" >Table</xsl:variable>
Add Xsl:param:
<xsl:template name= "dvt_2" >
<xsl:param name= "CustomerID"/>
<xsl:variable name= "StyleName" >Table</xsl:variable>
2) Apply Xsl:param and implement filtering
will <xsl:template name= "dvt_2" >
<xsl:param name= "CustomerID"/>
<xsl:variable name= "StyleName" >Table</xsl:variable>
<xsl:variable name= "Rows" select= ". /customers "/>
modified into:
<xsl:template name= "dvt_2" >
<xsl:param name= "CustomerID"/>
<xsl:variable name= "StyleName" >Table</xsl:variable>
<xsl:variable name= "Rows" select= ". /customers[normalize-space (CustomerID) = $CustomerID] "/>