1

In order to display the list column values in view mode, I have created a new custom form with type "Display Form" using Share-point Designer. When I open the file, I can see the code as (Attached the sample code only for reference), but when opened the browser using the URL https://*****.sharepoint.com/sites/***/subsite/Lists/Employee%20List/CustomDisplayForm.aspx?ID=14 I cannot see any data in the form.

   <tr>
        <td width="190px" valign="top" class="ms-formlabel">
            <H3 class="ms-standardheader">
                <nobr>Title</nobr>
            </H3>
        </td>
        <td width="400px" valign="top" class="ms-formbody">
            <xsl:value-of select="@Title"/>
        </td>
    </tr>
    <tr>
        <td width="190px" valign="top" class="ms-formlabel">
            <H3 class="ms-standardheader">
                <nobr>First Name</nobr>
            </H3>
        </td>
        <td width="400px" valign="top" class="ms-formbody">
            <xsl:value-of select="@First_x0020_Name"/>
        </td>
    </tr>

Can someone help me on this.

DataSource Code:

<DataSources>
<SharePoint:SPDataSource runat="server" DataSourceMode="ListItem" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Employee Content type&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" UseServerDataFormat="True"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://testsharepoint.sharepoint.com/sites/test/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{54AD5A3F-3309-47DD-BD8E-E32C90E05CED}" Name="ListID"></WebPartPages:DataFormParameter>
            </SelectParameters><UpdateParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://testsharepoint.sharepoint.com/sites/test/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{54AD5A3F-3309-47DD-BD8E-E32C90E05CED}" Name="ListID"></WebPartPages:DataFormParameter>
            </UpdateParameters><InsertParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://testsharepoint.sharepoint.com/sites/test/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{54AD5A3F-3309-47DD-BD8E-E32C90E05CED}" Name="ListID"></WebPartPages:DataFormParameter>
            </InsertParameters><DeleteParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://testsharepoint.sharepoint.com/sites/test/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{54AD5A3F-3309-47DD-BD8E-E32C90E05CED}" Name="ListID"></WebPartPages:DataFormParameter>
            </DeleteParameters>
</SharePoint:SPDataSource>
</DataSources>

Updated full code

<WebPartPages:DataFormWebPart runat="server" EnableOriginalValue="False" DisplayName="Employee List" ViewFlag="8" ViewContentTypeId="" Default="FALSE" ListName="{3ACA5686-58D3-4E36-AC8F-0D7812940950}" ListId="3aca5686-58d3-4e36-ac8f-0d7812940950" PageType="PAGE_EDITFORM" PageSize="-1" UseSQLDataSourcePaging="True" DataSourceID="" ShowWithSampleData="False" AsyncRefresh="False" ManualRefresh="False" AutoRefresh="False" AutoRefreshInterval="60" NoDefaultStyle="TRUE" InitialAsyncDataFetch="False" Title="Employee List" FrameType="None" SuppressWebPartChrome="False" Description="" IsIncluded="True" PartOrder="2" FrameState="Normal" AllowRemove="True" AllowZoneChange="True" AllowMinimize="True" AllowConnect="True" AllowEdit="True" AllowHide="True" IsVisible="True" DetailLink="" HelpLink="" HelpMode="Modeless" Dir="Default" PartImageSmall="" MissingAssembly="Cannot import this Web Part." PartImageLarge="" IsIncludedFilter="" ExportControlledProperties="True" ConnectionID="00000000-0000-0000-0000-000000000000" ID="g_2dfdb5ea_8282_4460_9480_e98c619f0bbd" ChromeType="None" ExportMode="All" __MarkupType="vsattributemarkup" __WebPartId="{2DFDB5EA-8282-4460-9480-E98C619F0BBD}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><DataSources>
<SharePoint:SPDataSource runat="server" DataSourceMode="ListItem" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Employee Employee Content type&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" UseServerDataFormat="True"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://sample.sharepoint.com/sites/sampletest/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{3ACA5686-58D3-4E36-AC8F-0D7812940950}" Name="ListID"></WebPartPages:DataFormParameter>
            </SelectParameters><UpdateParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://sample.sharepoint.com/sites/sampletest/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{3ACA5686-58D3-4E36-AC8F-0D7812940950}" Name="ListID"></WebPartPages:DataFormParameter>
            </UpdateParameters><InsertParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://sample.sharepoint.com/sites/sampletest/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{3ACA5686-58D3-4E36-AC8F-0D7812940950}" Name="ListID"></WebPartPages:DataFormParameter>
            </InsertParameters><DeleteParameters><WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="https://sample.sharepoint.com/sites/sampletest/sample" Name="weburl"></WebPartPages:DataFormParameter><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{3ACA5686-58D3-4E36-AC8F-0D7812940950}" Name="ListID"></WebPartPages:DataFormParameter>
            </DeleteParameters>
</SharePoint:SPDataSource>
</DataSources>
<Xsl>






<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:dsp="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="UserID" />
    <xsl:param name="WPPropertyBinding" />
    <xsl:param name="LogonUser"/>
    <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:dsp="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/15/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">ListForm</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
        <div>
            <span id="part1">
                <table border="0" width="100%">
                    <xsl:call-template name="dvt_1.body">
                        <xsl:with-param name="Rows" select="$Rows"/>
                    </xsl:call-template>
                </table>
            </span>
            <SharePoint:AttachmentUpload runat="server" ControlMode="Edit"/>
            <SharePoint:ItemHiddenVersion runat="server" ControlMode="Edit"/>
        </div>
    </xsl:template>
    <xsl:template name="dvt_1.body">
        <xsl:param name="Rows"/>
        <tr>
            <td class="ms-toolbar" nowrap="nowrap">
                <table>
                    <tr>
                        <td width="99%" class="ms-toolbar" nowrap="nowrap"><IMG SRC="/_layouts/15/images/blank.gif" width="1" height="18"/></td>
                        <td class="ms-toolbar" nowrap="nowrap">
                            <SharePoint:SaveButton runat="server" ControlMode="Edit" id="savebutton1"/>
                        </td>
                        <td class="ms-separator">&#160;</td>
                        <td class="ms-toolbar" nowrap="nowrap" align="right">
                            <SharePoint:GoBackButton runat="server" ControlMode="Edit" id="gobackbutton1"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="ms-toolbar" nowrap="nowrap">
                <SharePoint:FormToolBar runat="server" ControlMode="Edit"/>
                <SharePoint:ItemValidationFailedMessage runat="server" ControlMode="Edit"/>
            </td>
        </tr>
        <xsl:for-each select="$Rows">

            <xsl:call-template name="dvt_1.rowedit"/>
        </xsl:for-each>
        <tr>
            <td class="ms-toolbar" nowrap="nowrap">
                <table>
                    <tr>
                        <td class="ms-descriptiontext" nowrap="nowrap">
                            <SharePoint:CreatedModifiedInfo ControlMode="Edit" runat="server"/>
                        </td>
                        <td width="99%" class="ms-toolbar" nowrap="nowrap"><IMG SRC="/_layouts/15/images/blank.gif" width="1" height="18"/></td>
                        <td class="ms-toolbar" nowrap="nowrap">
                            <SharePoint:SaveButton runat="server" ControlMode="Edit" id="savebutton2"/>
                        </td>
                        <td class="ms-separator">&#160;</td>
                        <td class="ms-toolbar" nowrap="nowrap" align="right">
                            <SharePoint:GoBackButton runat="server" ControlMode="Edit" id="gobackbutton2"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </xsl:template>
    <xsl:template name="dvt_1.rowedit">
        <xsl:param name="Pos" select="position()"/>
        <tr>
            <td>

                <table border="0" cellspacing="0" width="100%">
                    <xsl:if test="@PaymentStatus = 'Demo JB'">
                        <tr>
                            <td width="190px" valign="top" class="ms-formlabel">
                                <H3 class="ms-standardheader">
                                    <nobr>Title<span class="ms-formvalidation"> *</span>
                                    </nobr>
                                </H3>
                            </td>
                            <td width="400px" valign="top" class="ms-formbody">
                                <SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
                                <SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="Edit"/>
                            </td>
                        </tr>
                    <tr>
                        <td width="190px" valign="top" class="ms-formlabel">
                            <H3 class="ms-standardheader">
                                <nobr>PaymentStatus</nobr>
                            </H3>
                        </td>
                        <td width="400px" valign="top" class="ms-formbody">
                            <SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="Edit" FieldName="PaymentStatus" __designer:bind="{ddwrt:DataBind('u',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@PaymentStatus')}"/>
                            <SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="PaymentStatus" ControlMode="Edit"/>

                        </td>
                    </tr>
                    </xsl:if>
                    <tr id="idAttachmentsRow">
                        <td nowrap="true" valign="top" class="ms-formlabel" width="20%">
                            <SharePoint:FieldLabel ControlMode="Edit" FieldName="Attachments" runat="server"/>
                        </td>
                        <td valign="top" class="ms-formbody" width="80%">
                            <SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="Edit" FieldName="Attachments" __designer:bind="{ddwrt:DataBind('u','AttachmentsField','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"/>
                            <script>
          var elm = document.getElementById("idAttachmentsTable");
          if (elm == null || elm.rows.length == 0)
          document.getElementById("idAttachmentsRow").style.display='none';
        </script>
                        </td>
                    </tr>
                        <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
                        <tr>
                            <td colspan="99" class="ms-vb">
                                <span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
                            </td>
                        </tr>
                    </xsl:if>
                </table>
            </td>
        </tr>
    </xsl:template>
</xsl:stylesheet>   </Xsl>
<DataFields>
</DataFields>
<ParameterBindings>
         <ParameterBinding Name="ListItemId" Location="QueryString(ID)" DefaultValue="0"/>
         <ParameterBinding Name="weburl" Location="None" DefaultValue="https://sample.sharepoint.com/sites/sampletest/sample"/>
         <ParameterBinding Name="ListID" Location="None" DefaultValue="{3ACA5686-58D3-4E36-AC8F-0D7812940950}"/>
         <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="LogonUser" Location = "ServerVariable(LOGON_USER)" />
         <ParameterBinding Name="WPPropertyBinding" Location="Control(@Nationality)"  DefaultValue="asssss" />
     </ParameterBindings>
</WebPartPages:DataFormWebPart>
14
  • 1
    @MarceloEspinosa Yes the QueryString ID = 14 has values in the list. If I open the same ID using custom Editor Form the values are binded properly
    – Vinod
    Commented Nov 21, 2016 at 13:27
  • 1
    @MarceloEspinosa This is what you have asked for correct?
    – Vinod
    Commented Nov 21, 2016 at 14:59
  • 1
    @MarceloEspinosa You meant to say whether I have set as default right? Yes. I have set the display form as Default.
    – Vinod
    Commented Nov 21, 2016 at 15:17
  • 1
    @MarceloEspinosa In the URL I am specifying ID so the ListItemld would be taken from QueryString.
    – Vinod
    Commented Nov 21, 2016 at 16:01
  • 1
    @MarceloEspinosa Checked that as well. Its not working too.
    – Vinod
    Commented Nov 22, 2016 at 13:42

2 Answers 2

0

Looking for all the code that you have pasted, and the problem that you have described, your issue must be:

<xsl:if test="@PaymentStatus = 'Demo JB'"></xsl:if>

You said it's not returning any data, make sure if the ID of item is correct and if the Column PaymentStatus of this item is equal to "Demo JB".

If you want to list the items even if the column PaymentStatus is different than "Demo JB" just delete your <xsl:if> tag.

1
  • My ID is valid and is available in the List. The condition you have mentioned is what I have also given, but even if the value is there for Payment Status column is Demo JB, its not entering into the if condition.
    – Vinod
    Commented Nov 22, 2016 at 12:19
-1

Please make sure that the the item available in the list with the ID specified in the query string. by default if you view it from the SharePoint Designer using the View in Browser option it will load the first item from the list.

3
  • Yes the QueryString ID = 14 has values in the list. If I open the same ID using custom Editor Form the values are binded properly
    – Vinod
    Commented Nov 21, 2016 at 12:19
  • make this form as a default display form of the list and try opening it
    – Esaki
    Commented Nov 21, 2016 at 12:21
  • Still the same. Values are blank
    – Vinod
    Commented Nov 21, 2016 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.