The Data View Web Part is a very useful web part, especially as it allows you to easily customize the display using XLST.
Below is some sample XSLT showing a very simple view of items in a document library. The view shows documents using the Title column and creates a clickable link to the document concerned using the FileRef column.
<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:template match="/"> <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/> <div class="ms-vb" style="margin-top:5px;padding-left:20px;"> <table border="0" cellpadding="0" cellspacing="0"> <xsl:for-each select="$Rows"> <tr class="ms-vb"> <td align="left" valign="middle" width="15px"><img src="/_layouts/images/square.gif" alt="" border="0" align="absmiddle" /></td> <td align="left" valign="middle"><a href="{@FileRef}"><xsl:value-of select="@Title"/></a></td> </tr> </xsl:for-each> </table> </div> </xsl:template> </xsl:stylesheet> </xsl>
Simple XSLT View for Data View Web Part
Published by