/ Published in: VB.NET
Sample DataView Webpart for SharePoint Designer 2010 demonstrating adding the WebURL parameter and renaming listID to listName.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<WebPartPages:DataFormWebPart runat="server" Description="" ListDisplayName="" PartOrder="4" HelpLink="" AllowRemove="True" IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="True" DataSourceID="" Title="N6 Staff" ViewFlag="8" NoDefaultStyle="TRUE" AllowConnect="True" FrameState="Normal" PageSize="-1" PartImageLarge="" AsyncRefresh="False" ExportMode="All" Dir="Default" DetailLink="" ShowWithSampleData="False" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{81D4C1D7-8202-4C51-8888-1D407293AE04}" __AllowXSLTEditing="true" WebPart="true" Height="" Width="400px"><ParameterBindings> <ParameterBinding Name="ListName" Location="None" DefaultValue="CSG10 Staff"/> <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/> <ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/> <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/> <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/> </ParameterBindings> <DataFields>@Title,Staff Name;@JobTitle,Title;@Rank,Rank;@N_x002d_Code,N-Code;@Department,Department;@WorkPhone,Business Phone;@Email_x0020__x0028_Unclass_x0029,Email;@Number,Number;@Name_x0020__x0026__x0020_Rank,Name & Rank;@ID,ID;@ContentType,Content Type;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@ItemChildCount,Item Child Count;@FolderChildCount,Folder Child Count;</DataFields> <Xsl> <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"> <xsl:output method="html" indent="no"/> <xsl:decimal-format NaN=""/> <xsl:param name="dvt_apos">'</xsl:param> <xsl:param name="ManualRefresh"></xsl:param><xsl:variable name="dvt_1_automode">0</xsl:variable> <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls"> <xsl:choose> <xsl:when test="($ManualRefresh = 'True')"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top"> <xsl:call-template name="dvt_1"/> </td> <td width="1%" class="ms-vb" valign="top"> <img src="/_layouts/images/staticrefresh.gif" id="ManualRefresh" border="0" onclick="javascript: {ddwrt:GenFireServerEvent('__cancel')}" alt="Click here to refresh the dataview."/> </td> </tr> </table> </xsl:when> <xsl:otherwise> <xsl:call-template name="dvt_1"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="dvt_1"> <xsl:variable name="dvt_StyleName">Table</xsl:variable> <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/> <xsl:variable name="dvt_RowCount" select="count($Rows)"/> <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" /> <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/> <xsl:choose> <xsl:when test="$dvt_IsEmpty"> <xsl:call-template name="dvt_1.empty"/> </xsl:when> <xsl:otherwise> <table border="0" width="100%" cellpadding="2" cellspacing="0"> <tr valign="top"> <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1"> <th class="ms-vh" width="1%" nowrap="nowrap"></th> </xsl:if><th class="ms-vh" nowrap="nowrap" style="font-family: Verdana, Helvetica, sans-serif; font-weight: normal; color: #003759; text-decoration: none">Position/Billet</th><th class="ms-vh" nowrap="nowrap">Name</th><th class="ms-vh" nowrap="nowrap">Phone</th></tr> <xsl:call-template name="dvt_1.body"> <xsl:with-param name="Rows" select="$Rows"/></xsl:call-template> </table> </xsl:otherwise> </xsl:choose></xsl:template> <xsl:template name="dvt_1.body"> <xsl:param name="Rows"/><xsl:for-each select="$Rows"> <xsl:call-template name="dvt_1.rowview" /> </xsl:for-each> </xsl:template> <xsl:template name="dvt_1.rowview"> <tr> <xsl:if test="position() mod 2 = 1"> <xsl:attribute name="class">ms-alternating</xsl:attribute> </xsl:if><td class="ms-vb"> <xsl:value-of select="@JobTitle" /></td><td class="ms-vb" width="150"> <xsl:value-of select="@Name_x0020__x0026__x0020_Rank" /></td><td class="ms-vb" width="100"> <xsl:value-of select="@WorkPhone" /></td><xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1"> <td class="ms-vb" width="1%" nowrap="nowrap"> <span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span> </td> </xsl:if> </tr> </xsl:template> <xsl:template name="dvt_1.empty"> <xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable> <table border="0" width="100%"> <tr> <td class="ms-vb"> <xsl:value-of select="$dvt_ViewEmptyText"/> </td> </tr> </table> </xsl:template></xsl:stylesheet></Xsl> <DataSources> <SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="<View><Query><Where><Eq><FieldRef Name="Department"/><Value Type="Text">6 - Communications</Value></Eq></Where><OrderBy><FieldRef Name="Number" Ascending="TRUE"/></OrderBy></Query></View>" UseInternalName="True" UseServerDataFormat="True" ID="dataformwebpart1"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="WebURL" PropertyName="ParameterValues" DefaultValue="/sites/csl/csg10" Name="WebURL"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="CSG10 Staff" Name="ListName"></WebPartPages:DataFormParameter> </SelectParameters> </SharePoint:SPDataSource> </DataSources> </WebPartPages:DataFormWebPart>