Render a HTML link with a DVWP in Sharepoint 2010

I am trying to link the list to the parent announcement article.  I figured out how to href the xsl item, but im not sure which property is correct because the URL doesnt generate correctly.  Any ideas? So far I have this:

<a><xsl:attribute name="href"><xsl:value-of select="@FileRef" /></xsl:attribute><xsl:value-of select="@LinkTitle"/></a>
 and it doesnt render right...
jhuntinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

can you give an example of what is rendered and what you would like to see instead?

cheers, teylyn
0
jhuntinAuthor Commented:
I attached the code snippet.

Essentially this is going to be a DVWP that will show the annoucements web part of its parent site.

Right now, the only field that I have added is the Title.  I would like that title to link back to the parent page annoucement.  I have tried the fileref and URL xsl value but neither will correctly complete the URL hyperlink back to the parent annoucement web part item correctly.
<WebPartPages:DataFormWebPart runat="server" Description="" ListDisplayName="" PartOrder="1" HelpLink="" AllowRemove="True" IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="True" DataSourceID="" Title="Announcements" ViewFlag="8" NoDefaultStyle="TRUE" AllowConnect="True" FrameState="Normal" PageSize="10" PartImageLarge="" AsyncRefresh="False" ExportMode="All" Dir="Default" DetailLink="" ShowWithSampleData="False" ListId="d34811e0-1c1b-43ee-8b3a-1e7c01669e2a" ListName="{D34811E0-1C1B-43EE-8B3A-1E7C01669E2A}" FrameType="Default" PartImageSmall="" IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" ManualRefresh="False" AutoRefresh="False" AutoRefreshInterval="60" AllowMinimize="True" ViewContentTypeId="" InitialAsyncDataFetch="False" MissingAssembly="Cannot import this Web Part." HelpMode="Modeless" ListUrl="" ID="g_faaa8692_2ed8_4eaa_8f96_c2a8cb6782aa" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{FAAA8692-2ED8-4EAA-8F96-C2A8CB6782AA}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><ParameterBindings>
														<ParameterBinding Name="ListID" Location="None" DefaultValue="{D34811E0-1C1B-43EE-8B3A-1E7C01669E2A}"/>
														<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"/>
														<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
														<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
														<ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
													</ParameterBindings>
<DataFields>@ID,ID;@ContentType,Content Type;@Title,Title;@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;@Body,Body;@Expires,Expires;</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">&apos;</xsl:param>
														<xsl:param name="ManualRefresh"></xsl:param>
														<xsl:param name="dvt_firstrow">1</xsl:param>
														<xsl:param name="dvt_nextpagedata" />
														<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="RowLimit" select="10" />
															<xsl:variable name="FirstRow" select="$dvt_firstrow" />
															<xsl:variable name="LastRow" select="$FirstRow + $dvt_RowCount - 1" />
															<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">LinkTitle</th>
					</tr>
					<xsl:call-template name="dvt_1.body">
						<xsl:with-param name="Rows" select="$Rows"/>
						<xsl:with-param name="FirstRow" select="1" />
						<xsl:with-param name="LastRow" select="$LastRow - $FirstRow + 1" />
					</xsl:call-template>
				</table>
			</xsl:otherwise>
															</xsl:choose>
															<xsl:call-template name="dvt_1.commandfooter">
																<xsl:with-param name="FirstRow" select="$FirstRow" />
																<xsl:with-param name="LastRow" select="$LastRow" />
																<xsl:with-param name="RowLimit" select="$RowLimit" />
																<xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
																<xsl:with-param name="RealLastRow" select="number(ddwrt:NameChanged('',-100))" />
															</xsl:call-template>
														</xsl:template>
														<xsl:template name="dvt_1.body">
															<xsl:param name="Rows"/>
															<xsl:param name="FirstRow" />
															<xsl:param name="LastRow" />
															<xsl:for-each select="$Rows">
																<xsl:variable name="dvt_KeepItemsTogether" select="false()" />
																<xsl:variable name="dvt_HideGroupDetail" select="false()" />
																<xsl:if test="(position() &gt;= $FirstRow and position() &lt;= $LastRow) or $dvt_KeepItemsTogether">
																	<xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
																		<xsl:call-template name="dvt_1.rowview" />
																	</xsl:if>
																</xsl:if>
															</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>
			<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>
			<td class="ms-vb">
				<a><xsl:attribute name="href"><xsl:value-of select="@FileRef" /></xsl:attribute><xsl:value-of select="@LinkTitle"/></a>
			</td>
		</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:template name="dvt_1.commandfooter">
															<xsl:param name="FirstRow" />
															<xsl:param name="LastRow" />
															<xsl:param name="RowLimit" />
															<xsl:param name="dvt_RowCount" />
															<xsl:param name="RealLastRow" />
															<table cellspacing="0" cellpadding="4" border="0" width="100%">
			<tr>
				<xsl:if test="$FirstRow &gt; 1 or $dvt_nextpagedata">
					<xsl:call-template name="dvt_1.navigation">
						<xsl:with-param name="FirstRow" select="$FirstRow" />
						<xsl:with-param name="LastRow" select="$LastRow" />
						<xsl:with-param name="RowLimit" select="$RowLimit" />
						<xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
						<xsl:with-param name="RealLastRow" select="$RealLastRow" />
					</xsl:call-template>
				</xsl:if>
																</tr>
		</table>
														</xsl:template>
														<xsl:template name="dvt_1.navigation">
															<xsl:param name="FirstRow" />
															<xsl:param name="LastRow" />
															<xsl:param name="RowLimit" />
															<xsl:param name="dvt_RowCount" />
															<xsl:param name="RealLastRow" />
															<xsl:variable name="PrevRow">
																<xsl:choose>
																	<xsl:when test="$FirstRow - $RowLimit &lt; 1">1</xsl:when>
																	<xsl:otherwise>
					<xsl:value-of select="$FirstRow - $RowLimit" />
				</xsl:otherwise>
																</xsl:choose>
															</xsl:variable>
															<xsl:variable name="LastRowValue">
																<xsl:choose>
																	<xsl:when test="$LastRow &gt; $RealLastRow">
					<xsl:value-of select="$LastRow"></xsl:value-of>
				</xsl:when>
																	<xsl:otherwise>
					<xsl:value-of select="$RealLastRow"></xsl:value-of>
				</xsl:otherwise>
																</xsl:choose>
															</xsl:variable>
															<xsl:variable name="NextRow">
			<xsl:value-of select="$LastRowValue + 1"></xsl:value-of>
		</xsl:variable>
															<td nowrap="nowrap" class="ms-paging" align="right">
																<xsl:if test="$dvt_firstrow &gt; 1" ddwrt:cf_ignore="1">
				<a>
																	<xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent('dvt_firstrow={1};dvt_startposition={}')" />;</xsl:attribute>
																	Start</a>
																	<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
																	<a>
																	<xsl:attribute name="href">javascript: history.back();</xsl:attribute>
																	<img src="/_layouts/images/prev.gif" border="0" alt="Previous" />
																	</a>
																	<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
																</xsl:if>
																<xsl:value-of select="$FirstRow" />
																 - <xsl:value-of select="$LastRowValue" />
																<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">&amp;nbsp;</xsl:text>
																
																<xsl:if test="$LastRowValue &lt; $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1">
				<a>
																	<xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'};dvt_startposition={',$dvt_nextpagedata,'}'))" />;</xsl:attribute>
																	<img src="/_layouts/images/next.gif" border="0" alt="Next" />
																	</a>
			</xsl:if>
															</td>
														</xsl:template>
													</xsl:stylesheet></Xsl>
<DataSources>
<SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;/View&gt;" UseInternalName="True" UseServerDataFormat="True" ID="dataformwebpart1"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{D34811E0-1C1B-43EE-8B3A-1E7C01669E2A}" Name="ListID"></WebPartPages:DataFormParameter><asp:Parameter DefaultValue="0" Name="StartRowIndex"></asp:Parameter><asp:Parameter DefaultValue="0" Name="nextpagedata"></asp:Parameter><asp:Parameter DefaultValue="10" Name="MaximumRows"></asp:Parameter>
</SelectParameters><UpdateParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{D34811E0-1C1B-43EE-8B3A-1E7C01669E2A}" Name="ListID"></WebPartPages:DataFormParameter>
</UpdateParameters><InsertParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{D34811E0-1C1B-43EE-8B3A-1E7C01669E2A}" Name="ListID"></WebPartPages:DataFormParameter>
</InsertParameters><DeleteParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{D34811E0-1C1B-43EE-8B3A-1E7C01669E2A}" Name="ListID"></WebPartPages:DataFormParameter>
</DeleteParameters>
</SharePoint:SPDataSource>
</DataSources>
</WebPartPages:DataFormWebPart>

Open in new window

0
jhuntinAuthor Commented:
Line 106 is where you are looking for, btw. Thanks.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

you may want to try (starting from row 105 in your code snippet above)

<td class="ms-vb">
    <a href="{@FileRef}"><xsl:value-of select="@LinkTitle" /></a>
</td>

Open in new window


That will generate a link to the actual file (document, aspx page, whatever) and display the field LinkTitle in the user interface.

cheers, teylyn

0
jhuntinAuthor Commented:
Well, I would assume that the link would be back to the main page annoucements but what is being generated is: http://xxx.xxx.xxx.xxx/parent/child/Lists/Announcements/1_.000

The link goes to a 404 error. The info that is being populated comes from the correct annoucements list...just the link doesnt seem to want to go there correctly. Ever seen this before?
0
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
It's late at night where I live and I'm about to crash. If nobody else steps in, I'll work on this first thing tomorrow.

cheers, teylyn
0
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello again,

I've created a DVWP with an Announcement list as the data source. The xsl I posted above does indeed not render an Announcement item correctly, but it does so for a document library item.

To display a link to the Announcement item, I inserted the ID field into the DVWP:

- in Design view, click the cell where you want the link to be and remove all other contents.
- in the Data Source panel, find the ID field, right-click it and select "Insert as Hyperlink to Display Form". This will render code along the lines of

<td class="ms-vb">
     <a href="http://ServerName/sites/SiteName/Lists/Announcements/DispForm.aspx?ID={@ID}">
          <xsl:value-of select="@ID" />
     </a>
</td>

Open in new window


The DVWP will now show the item ID as a link, and when you click it, it will open the announcement in view mode.

In SharePoint Designer, switch back to code View and adjust the text between the <a> tags to

<xsl:value-of select="@Title" />

The whole cell now should be

<td class="ms-vb">
     <a href="http://ServerName/sites/SiteName/Lists/Announcements/DispForm.aspx?ID={@ID}">
          <xsl:value-of select="@Title" />
     </a>
</td>

Open in new window


Now the DVWP will show the Announcement title as a link to the announcement.

cheers, teylyn
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.