我有一个<asp:ListView>
但由于某种原因,当列表为空时,LayoutTemplate 部分不会显示,尽管 <EmptyDataTemplate>
部分显示。 LayoutTemplate 包含表的标题,我想在数据源中没有项目时显示一个空表,而不仅仅是 EmptyDataTemplate 的内容。
如果别无选择,我会将 LayoutTemplate 复制到 EmptyDataTemplate 中,但必须这样做似乎很愚蠢。有想法吗?
最佳答案
来自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.
这里的关键词是“...模板被渲染而不是 LayoutTemplate
模板...”
所以我认为,您必须将 LayoutTemplate
复制到 EmptyDataTemplate
模板中。
关于asp.net - ListView LayoutTemplate 在为空时不显示 asp.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5500296/