EmptyData

in namespace DotVVM.Framework.Controls

Content of this control is displayed if and only if DataSource is empty or null

Usage & Scenarios

Allows to display content if and only if DataSource is empty or null. The property EmptyDataTemplate in the Repeater has similar behaviour but the usage is limited only inside Repeater.

Sample 1: Basic Usage

The Customers is a property of List<Customer> in the viewmodel.

The EmptyData content is displayed when Customers collection is empty or null.

<dot:EmptyData DataSource="{value: Customers}">
  <p class="error">No customers found</p>
</dot:EmptyData>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DotVVM.Framework.Controls;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.builtin.EmptyData.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public List<Customer> Customers { get; set; } = new List<Customer>();
    }


    public class Customer
    {
        public int Id { get; set; }
        public string Name { get; set; }

        public Customer()
        {
            // NOTE: This default constructor is required. 
            // Remember that the viewmodel is JSON-serialized
            // which requires all objects to have a public 
            // parameterless constructor
        }

        public Customer(int id, string name)
        {
            Id = id;
            Name = name;
        }
    }
}

Properties

Name Type Description Notes Default Value
property icon DataSource Object Gets or sets the source collection or a GridViewDataSet that contains data in the control.
attribute
inner element
static value
bindable
default
null
property icon RenderWrapperTag Boolean Gets or sets whether the control should render a wrapper element.
attribute
inner element
static value
bindable
default
True
property icon WrapperTagName String Gets or sets the name of the tag that wraps the Repeater.
attribute
inner element
static value
bindable
default
div

HTML produced by the control

The control renders the contents if and only if DataSource is empty or null. Optionally you can enable wrapper tag rendering using the RenderWrapperTag property. The tag name can be changed using the WrapperTagName property.

<div>
    <!-- If DataSource is empty or null content is rendered here -->
</div>