正如问题中所指出的:
其中一种解决方案是禁用GridView组件的地址器(如这个答案中指定的)。
是否有一种解决方案,允许将CSS友好控制适配器用于GridView并仍然利用EmptyDataTemplate功能?
发布于 2011-04-28 21:43:58
从源代码构建the友好,而不是使用下载链接。目前,最新的是http://cssfriendly.codeplex.com/SourceControl/changeset/changes/24242和EmptyDataText在我使用该源代码时运行良好。
发布于 2010-10-05 02:36:40
如果您查看链接中提供的CSS友好的GridView适配器的源代码,您将看到以下内容(注意缺少的else):
private void WriteRows(HtmlTextWriter writer, GridView gridView, GridViewRowCollection rows, string tableSection)
{
if (rows.Count > 0)
{基本上,适配器没有提到EmptyDataTemplate或EmptyDataText --这是一个简单的疏忽。不过,修补它是很简单的。您所要做的就是获取所提供的源代码,查看原始GridView如何呈现它,合并概念,并重新构建原始适配器:
case DataControlRowType.EmptyDataRow:
if (this._emptyDataTemplate == null)
{
container = new TableCell();
string emptyDataText = this.EmptyDataText;
if (emptyDataText.Length > 0)
{
container.Text = emptyDataText;
}
break;
}
container = new TableCell();
template = this._emptyDataTemplate;
break;
}
if (container != null)
{
if (columnSpan > 1)
{
container.ColumnSpan = columnSpan;
}
if (template != null)
{
template.InstantiateIn(container);
}
row.Cells.Add(container);
}发布于 2010-10-21 02:01:06
在/ RenderContents /节/之前,在RenderContents中的GridViewAdapter.cs中添加以下内容
if (gridView.Rows.Count == 0) {
//Control[0].Control[0] s/b the EmptyDataTemplate.
if (gridView.HasControls()) {
if (gridView.Controls[0].HasControls()) {
if (gridView.Controls[0].Controls[0] is GridViewRow) {
rows.Clear();
rows.Add(gridView.Controls[0].Controls[0]);
gvrc = new GridViewRowCollection(rows);
WriteRows(writer, gridView, gvrc, "tfoot");
}
}
}
} 并在返回GetRowClass ()之前将以下内容添加到className.Trim();
//// EmptyDataTemplate
if ((row.RowType & DataControlRowType.EmptyDataRow) == DataControlRowType.EmptyDataRow) {
className += " AspNet-GridView-Empty ";
}最后,如果您想要覆盖标准的the样式,请添加一个CSS部分。
.AspNet-GridView table tfoot tr.AspNet-GridView-Empty td
{
}https://stackoverflow.com/questions/3856890
复制相似问题