More in this section
Forums / Developing with Sitefinity / How to Hide Empty Event Fields?

How to Hide Empty Event Fields?

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. ncacpa
    ncacpa avatar
    3 posts
    27 Mar 2009
    06 Apr 2010
    Link to this post
    I need to be able to hide labels/rows of event fields that do not have any data (see attached screenshot).
    How can I hide fields that are empty/blank on the event detail view? It looks really tacky to have labels with no data - I'd like the event detail view to only show labels of event fields that do have data (and hide the blank fields altogether - including the label).
    By the way - I've tried using external templates (~/Sitefinity/ControlTemplates/Events/ContentViewSingleItemView.ascx) but for some reason that's not working (no change I make shows up) - so if possible please provide a solution to address the issue w/out having to use external templates.

    I'm using Sitefinity 3.7 SP3

    Thank you.
    - Chris
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    01 Feb 2016
    07 Apr 2010
    Link to this post
    Hello ncacpa,

    Thank you for using our services.

    There are some static texts in the control templates for the Events View control. What you can do is to set the Events View control to use the external templates which can be found in ~/Sitefinity/Admin/ControlTemplates/Events/Modes. To do this open the Events View control for edit go to Advanced->Appearance and set SingleItemTemplatePath and ItemListTemplatePath as in attached image.

    Then you can edit the control template to have labels instead of static texts. For example:
    <address id="Location" runat="server" class="sf_eventLocation">
        <asp:Label ID="streetLbl" runat="server" AssociatedControlID="Street" Text="Street"></asp:Label> <asp:Literal ID="Street" runat="server" Text="{0}" /><br />

    and on page load check if the control associated with this label has some text. If not hide the label:
    <script type="text/C#" runat="server">
        protected void Page_Load()
            Literal strliteral = (Literal)this.FindControl(streetLbl.AssociatedControlID);
            if (strliteral.Text == "")
                streetLbl.Visible = false;

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. James
    James avatar
    1 posts
    17 Aug 2012
    07 Aug 2012
    Link to this post
    We had a similar issue where we were displaying data in a control from a custom module, but wanted to hide labels if there was no data for a field. Looking for help, found this thread, and although we're on 5.x, thought something similar might work on earlier versions. At least worth  adding a bit of sample template code that worked for us:

    <sf:SitefinityLabel Visible='<%# (Eval("Email")=="" ? false : true) %>' Text="<strong>Email:</strong> " runat="server" />
    <sf:sitefinityhyperlink ID="EmailLink" runat="server" navigateurl='<%# Eval("Email","mailto:{0}") %>' Text='<%# Eval("Email") %>' />

Register for webinar
3 posts, 0 answered