none
custom error message in business data list web part

    Pertanyaan

  • Hi All,

    I am using SharePoint 2007 Business Data List web part to show external information retrieved from LOB sql DB.
    Is there ability to show custom error message on Business Data List web part if the filter does not return any data?
     
    Thanks,
    -N
    19 Januari 2012 15:00

Semua Balasan

  • Hi Nilesh

     

    You can use to retrieve data from your custom web service.  The following code snippets is a sample to achieve your requirement:

    string formRecipient;

             [

                 Personalizable(PersonalizationScope.Shared),

                 WebBrowsable(true),

                 WebDisplayName("Form Recipient Email"),

                 WebDescription("Email address of the complaint administrator")

             ]

             public string FormRecipient

             {

                 get { return formRecipient; }

                 set

                 {

                     if (!ValidEmail(value))

                     {

                         throw new WebPartPageUserException(”Invalid ‘Form Recipient’ email address. Only one valid email address permitted by the system.”);

                     }

                     else

                     {

                         formRecipient = value;

                     }

                 }

             }

     

    For more information, please refer to following links:

    A similar question: http://social.msdn.microsoft.com/Forums/ar/sharepointbdc/thread/4cc28a50-4f34-4eb2-ad73-c828aae99e13

    http://support.microsoft.com/kb/944105/en-us

    http://www.associatedcontent.com/article/6077894/how_to_turn_on_custom_error_messages_pg2.html?cat=15

     

    Thanks,

    Lhan Han

    20 Januari 2012 2:42
    Moderator
  • Hi Lhan,

    I'm looking for something like below screen shot:

    Instead of below default error message:

    25 Januari 2012 10:21
  • Hey Nilesh,

    Can you look into the xsl generated for the above webpart. If you can, find the empty row template(displayed when no rows are returned from webpart). You can customize this generic error message. You need to spend some time in figuring out how you can play with different templates; to be used for different filter conditions you have specified for the user to choose from. Look into the below code which we use for providing sorting on a page:

                     

    <th class="table-heading">
    
                        <xsl:if test="($field != 'ows_Title') or  ($field ='ows_Title' and  $direction='descending')">
    
                          <a href="?{$pagingAtt}=,,ows_Title,ascending{$qr}">Title </a>
    
                          <img border="0" width="7px" height="5px" src="../../Style Library/Images/sort-d.gif" class="pad5"/>
    
                        </xsl:if>
    
                        <xsl:if test="$field = 'ows_Title' and $direction = 'ascending' ">
    
                          <a href="?{$pagingAtt}=,,ows_Title,descending{$qr}">Title </a>
    
                          <img width="7px" height="5px" border="0" src="../../Style Library/Images/sort.gif" class="pad5"/>
    
                        </xsl:if>
    
                      </th>
    
                    </tr>
    
                    <xsl:if test="$field ='' and $direction =''">
    
                      <xsl:call-template name="meetingsItem"></xsl:call-template>
    
                    </xsl:if>
    
                    <xsl:if test="$field = 'ows_Title' and $direction = 'ascending'">
    
                      <xsl:call-template name="TitleAsc"></xsl:call-template>
    
                    </xsl:if>
    
                    <xsl:if test="$field = 'ows_Title' and $direction = 'descending'">
    
                      <xsl:call-template name="TitleDec"></xsl:call-template>
    
                    </xsl:if>
    
     
    
                    <tr>
    
                      <td colspan="4">
    
                      <div class="paging-panel">
    
                                    <div class="paging-div">
    
                                   
    
                                    </div>
    
                      </div>
    
                    </td>
    
                    </tr>
    
                        </table-->
    
                      </td>
    
                    </tr>
    
                  </table>
    
                </div>
    
              </div>
    
            </td>
    
          </tr>
    
        </table>
    
      </xsl:template>
    
      <xsl:variable name="Last" select="$First + $limit -1"/> 
    
      <xsl:template name="meetingsItem">
        <xsl:for-each select="$Rows">
          <tr>
            <xsl:if test="position() mod 2 = 1">
              <xsl:attribute name="class">td-odd</xsl:attribute>
            </xsl:if>
            <xsl:if test="position() mod 2 = 0">
              <xsl:attribute name="class">td-even</xsl:attribute>
            </xsl:if>
            <td>
              <a href="MeetingDetails.aspx?meetingid={@ows_ID}">
                <xsl:value-of select="@ows_Title"/>
              </a>
            </td>
          </tr>
        </xsl:for-each>
      </xsl:template>
    
      <xsl:template name="TitleAsc">
        <xsl:for-each select="$Rows">
          <xsl:sort data-type="text" order="ascending" select="@ows_Title"/>
          <tr>
            <xsl:if test="@ows_ID mod 2 = 1">
              <xsl:attribute name="class">td-odd</xsl:attribute>
            </xsl:if>
            <xsl:if test="@ows_ID mod 2 = 0">
              <xsl:attribute name="class">td-even</xsl:attribute>
            </xsl:if>
            <td>
              <a href="MeetingDetails.aspx?meetingid={@ows_ID}">
                <xsl:value-of select="@ows_Title"/>
              </a>
            </td>
          </tr>
        </xsl:for-each>
      </xsl:template>
      <xsl:template name="TitleDec">
        <xsl:for-each select="$Rows">
          <xsl:sort data-type="text" order="descending" select="@ows_Title"/>
          <tr>
            <xsl:if test="@ows_ID mod 2 = 1">
              <xsl:attribute name="class">td-odd</xsl:attribute>
            </xsl:if>
            <xsl:if test="@ows_ID mod 2 = 0">
              <xsl:attribute name="class">td-even</xsl:attribute>
            </xsl:if>
            <td>
              <a href="MeetingDetails.aspx?meetingid={@ows_ID}">
                <xsl:value-of select="@ows_Title"/>
              </a>
            </td>
          </tr>
        </xsl:for-each>
      </xsl:template>

    01 Februari 2012 6:56