Version: 2.0 |

EmptyData

in namespace DotVVM.Framework.Controls

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

Properties

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

Events

Name Type Description

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.

HTML Rendered 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>

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.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;
        }
    }
}

Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message