asp.net - ListView LayoutTemplate 在为空时不显示 asp.net

标签 asp.net listview

我有一个<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 the InsertItemPosition property is set to InsertItemPosition.None. The template is rendered instead of the LayoutTemplate template. If the InsertItemPosition property is set to a value other than InsertItemPosition.None, the EmptyDataTemplate template is not rendered.

这里的关键词是“...模板被渲染而不是 LayoutTemplate 模板...”

所以我认为,您必须将 LayoutTemplate 复制到 EmptyDataTemplate 模板中。

关于asp.net - ListView LayoutTemplate 在为空时不显示 asp.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5500296/

相关文章:

android - 当将 EditText 聚焦在 ListView 或 RecyclerView 中时,键盘显示但滚动不起作用

asp.net - 将代码部署到服务器后,样式表的工作方式有所不同

c# - SignalR 2.0 错误 : Could not load file or assembly Microsoft. Owin.Security

Jquery从表列表中隐藏单个表中的图像

listview - flutter 中非动态容器小部件的水平传送带

android - Listview 仅在滚动后显示图像

asp.net - 从通过 __doPostBack() 完成的页面中使用 Python 的 urllib 检索信息?

c# - JavaScript 的 window.focus() 不适用于 IE9

android - 您能指出这段代码中 ListView 的问题吗?

android - 如何在对话框 ListView 中设置 onItemClickListener()?