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 | |
|---|---|---|---|---|---|
| Attributes | Dictionary<String,Object> |
attribute
static value
|
null | ||
| ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
| DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. |
attribute
static value
bindable
|
null | |
| DataSource | Object | Gets or sets the source collection or a GridViewDataSet that contains data in the control. |
attribute
bindable
|
null | |
| ID | String | Gets or sets the unique control ID. |
attribute
static value
bindable
|
null | |
| IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
bindable
|
True | |
| InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
| RenderWrapperTag | Boolean | Gets or sets whether the control should render a wrapper element. |
attribute
static value
|
True | |
| Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True | |
| WrapperTagName | String | Gets or sets the name of the tag that wraps the Repeater. |
attribute
static value
|
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>