• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
Microsoft Developer Network
 
 
Home
 
 
Library
 
 
Learn
 
 
Downloads
 
 
Support
 
 
Community
 
 
Forums
 
 
 
Microsoft Developer Network > SharePoint Products and Technologies Forums > SharePoint - Business Data Catalog > Business Data List web part, format field from database as hyperlink
Ask a questionAsk a question
Search Forums:
  • Search SharePoint - Business Data Catalog Forum Search SharePoint - Business Data Catalog Forum
  • Search All SharePoint Products and Technologies Forums Search All SharePoint Products and Technologies Forums
  • Search All MSDN Forums Search All MSDN Forums
 

AnswerBusiness Data List web part, format field from database as hyperlink

  • Tuesday, December 23, 2008 2:36 PMjandho Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Hi,

    I have a BDC with an entity that selects fields from a table. One of the fields is the full pathname to a file, or it could be a hyperlink.
    When I display the entity in a Business Data List Web Part, all fields are displayed as text, without any formatting. I know the formatting can be modified using the XSL editor (under modify web part), I have found a sample with date-time format . Some basic formatting can also be done with de sharePoint designer, but nowhere have I found an example that allows me to format the column with the link as a clickable hyperlink.
    My strong points are sql server and .net , but not XSL , can anyone give me an example of how th eformatting needs to be done in XSL?

    tnx in advance


    Jan D'Hondt - Database and .NET development
    • ReplyReply
    • QuoteQuote
     

Answers

  • Tuesday, January 06, 2009 4:31 PMjandho Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Vote As Helpful
    0
    Ben,

    thank you for the reply.

    this is what I cooked from your answer and some others that I found on the web.
    Remember, the XSL I am editing is for a Business Data List web part. My Datafield contains an absolute url. so I had to find out where in the XSL was the formatting of the cell values (not the headers).

    Original XSL

     

          <td class="ms-vb">
            <xsl:attribute name="style">
              <xsl:choose>
                <xsl:when test="$dvt_1_form_selectkey = @*[name()=$ColumnKey]">color:blue</xsl:when>
                <xsl:otherwise />
              </xsl:choose>
            </xsl:attribute>
            <xsl:variable name="fieldValue">
              <xsl:call-template name="LFtoBR">
                <xsl:with-param name="input">
                  <xsl:value-of select="@DocumentationLink" />
                </xsl:with-param>
              </xsl:call-template>
            </xsl:variable>
            <xsl:copy-of select="$fieldValue" />
          </td>

     

    Modified XSL

     

          <td class="ms-vb">
            <xsl:attribute name="style">
              <xsl:choose>
                <xsl:when test="$dvt_1_form_selectkey = @*[name()=$ColumnKey]">color:blue</xsl:when>
                <xsl:otherwise />
              </xsl:choose>
            </xsl:attribute>
              <a target="_blank" href="{@DocumentationLink
    }">
                  <xsl:value-of select="@DocumentationLink" />
               </a>

          </td>


    Jan D'Hondt - Database and .NET development
    • Marked As Answer byjandho Tuesday, January 06, 2009 4:34 PM
    •  
    • ReplyReply
    • QuoteQuote
     

All Replies

  • Tuesday, December 30, 2008 7:02 PMBen Cline1MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Vote As Helpful
    1
    Sure, here is an example of how I formatted a field to show an image: http://social.msdn.microsoft.com/Forums/en-US/sharepointbdc/thread/d2b18c36-c5b4-43d3-bae2-d9fd2b491a29. In the web part properties you can see the default XSL and then find the field you want to modify.

    If you want to format it for a hyperlink and the field name is LinkUrl you can do it like this:

    <xsl:element name="a">     
       <xsl:attribute name="href"><xsl:value-of select="@LinkUrl" /></xsl:attribute>    
    </xsl:element>    
     

    The above example assumes the LinkUrl has the absolute path in it. If you need to append text to the value and LinkUrl is a relative path you could do something like this:

    <xsl:element name="a">     
                <xsl:attribute name="href">http://www.mysite.com/path/<xsl:value-of select="@LinkUrl" /></xsl:attribute>    
    </xsl:element>    
     

    Let me know if you have any questions on this, I would be glad to help.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    • ReplyReply
    • QuoteQuote
     
  • Tuesday, January 06, 2009 4:57 PMBen Cline1MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    I was definitely referring to the values not the headers, which are found in a different section of the XSL entirely.
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    • ReplyReply
    • QuoteQuote
     
  • Thursday, January 08, 2009 1:13 PMjandho Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    The solution I have shown above is for the values , not for the headers. I see a column headers like usual and the a series of rows with the cell values formatted as hyperlinks. 
    Jan D'Hondt - Database and .NET development
    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement