ListView的LayoutTemplate模板不显示,当空asp.net [英] ListView LayoutTemplate does not show when empty asp.net

查看:316
本文介绍了ListView的LayoutTemplate模板不显示,当空asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< ASP:ListView控件> 但由于某些原因,当列表为空的LayoutTemplate模板部分不显示,虽然&LT ; EmptyDataTemplate> 部分节目。该LayoutTemplate模板包含表的标题,我想显示一个空表时有数据源中没有任何项目,EmptyDataTemplate的不只是内容。

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.

如果没有选择,我会在LayoutTemplate模板复制到EmptyDataTemplate但它似乎愚蠢不得不这样做。想法?

If there is no choice I will copy the LayoutTemplate into EmptyDataTemplate but it seems stupid to have to do this. Ideas?

推荐答案

从<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.emptydatatemplate.aspx\">MSDN:

空模板显示在
  的ListView 控制当数据源
  绑定到该控件不
  包含任何记录和
   InsertItemPosition 属性设置为
   InsertItemPosition.None 。模板
  代替呈现的
   LayoutTemplate模板模板。如果
   InsertItemPosition 属性设置为
  以外的值
   InsertItemPosition.None 中,
   EmptyDataTemplate 模板不可
  渲染。

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模板模板...

the key words here are "...the template is rendered instead of the LayoutTemplate template..."

所以,我认为,你必须复制 LayoutTemplate模板 EmptyDataTemplate 模板。

So I think, you have to copy the LayoutTemplate into the EmptyDataTemplate template.

这篇关于ListView的LayoutTemplate模板不显示,当空asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆