I have an <asp:ListView>
but for some reason the LayoutTemplate section does not show when the list is empty, although the <EmptyDataTemplate>
section shows. The LayoutTemplate contains the headers for the table, and I want to show an empty table when there are no items in the datasource, not just the content of EmptyDataTemplate.
If there is no choice I will copy the LayoutTemplate into EmptyDataTemplate but it seems stupid to have to do this. Ideas?
From the MSDN:
The empty template is displayed in a
ListView
control when the data source that is bound to the control does not contain any records and theInsertItemPosition
property is set toInsertItemPosition.None
. The template is rendered instead of theLayoutTemplate
template. If theInsertItemPosition
property is set to a value other thanInsertItemPosition.None
, theEmptyDataTemplate
template is not rendered.
the key words here are "...the template is rendered instead of the LayoutTemplate
template..."
So I think, you have to copy the LayoutTemplate
into the EmptyDataTemplate
template.