我有一个<asp:ListView>
但由于某种原因,当列表为空时 LayoutTemplate 部分不会显示,尽管<EmptyDataTemplate>
部分显示。 LayoutTemplate 包含表的标题,当数据源中没有项目时,我想显示一个空表,而不仅仅是 EmptyDataTemplate 的内容。
如果别无选择,我会将 LayoutTemplate 复制到 EmptyDataTemplate 中,但必须这样做似乎很愚蠢。有想法吗?
来自MSDN http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.emptydatatemplate.aspx:
空模板显示在ListView
控制数据源何时
绑定到控件不
包含任何记录和InsertItemPosition
属性设置为InsertItemPosition.None
。模板
被渲染而不是LayoutTemplate
模板。如果InsertItemPosition
属性设置为
以外的值InsertItemPosition.None
, the
EmptyDataTemplate
模板不是
呈现。
这里的关键词是“...模板被渲染instead of the LayoutTemplate
模板...”
所以我认为,你必须复制LayoutTemplate
进入EmptyDataTemplate
模板。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)