问题描述
我似乎无法得到无论是的
工作 EmptyDataTemplate
或 EmptyDataText
GridView控件
我在取德codebehind的 GridView控件
内容并使用它们连接的DataBind()
。我试着让他们为空
和一个空的列表
,并在这两种情况下,我把到文本 EmptyDataTemplate
或 EmptyDataText
不显示。
我在做什么错了?
修改(code段)
这是我的GridView的:
< ASP:GridView控件ID =网格=服务器EmptyDataText =空>
< / ASP:GridView的>
和我已经试过这两种绑定的数据:
grid.DataSource =新的List<对象>();
grid.DataBind();grid.DataSource = NULL;
grid.DataBind();
这问题通过使用所谓的。有了它们启用(他们似乎默认启用), EmptyDataTemplate
和 EmptyDataText
不正常工作。
要禁用适配器,转到 App_Browsers文件
文件夹,并在 CSSFriendlyAdapters.browser
文件中注释掉以下部分(或与您所使用的控制部分):
<适配器controlType =System.Web.UI.WebControls.GridView
适配器类型=CSSFriendly.GridViewAdapter/>
最大的问题是样式会自行消失。
I can't seem to get either EmptyDataTemplate
or EmptyDataText
of a GridView
to work.
I'm fetching the GridView
contents in de codebehind and attaching them with using DataBind()
. I've tried having them as null
and as an empty List
, and in both cases the text I put into EmptyDataTemplate
or EmptyDataText
is not displayed.
What am I doing wrong?
EDIT (Code snippet)
This is my GridView:
<asp:GridView ID="grid" runat="server" EmptyDataText="EMPTY">
</asp:GridView>
And I've tried these two for binding the data:
grid.DataSource = new List<object>();
grid.DataBind();
grid.DataSource = null;
grid.DataBind();
This problem is caused by using the so-called CSS-Friendly Control Adapters. With them enabled (and they seem to be enabled by default), EmptyDataTemplate
and EmptyDataText
don't work as expected.
To disable the adapters, go to the App_Browsers
folder, and in the CSSFriendlyAdapters.browser
file, comment out the following section (or the section related to the control you're using):
<adapter controlType="System.Web.UI.WebControls.GridView"
adapterType="CSSFriendly.GridViewAdapter" />
The big problem is the styles will go away.
这篇关于EmptyDataTemplate和EmptyDataText在GridView控件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!