日期:2014-05-17  浏览次数:20481 次

记录返回是空时,gridview要显示标题???
就算是空,也得有个头标题出来。

但是现实中,它不可能出来, 只要是空gridview 就会不显示了。


原来在VS2005的时候是可以通过插入一条空值,然后就能实现了。 但是在VS2010的时候。 “ReturnNullTable" 说是没这个类, 如何在VS2010实现??


--------------VS2005 代码-------------------------
  DataTable dtable;
  if (记录为0)
  {
  dtable = MasterPage.ReturnNullTable(GridView1);
  GridView1.DataSource = dtable;
  GridView1.DataBind();
  return;
  }


-------------VS2010代码呢?-------??????

------解决方案--------------------
这是不是自定义的方法啊,你在哪看到的有ReturnNullTable方法
------解决方案--------------------
加个样式试试,希望有用
GridView runat="server" AllowSorting="True"
AutoGenerateColumns="False" CssClass="GridTable"
EmptyDataText="<span style=color:red>未找到符合条件的数据!</span>" EmptyShowHeader="True" HeaderStyle-Wrap="false"
BackColor="White" CellPadding="2">
<RowStyle CssClass="Row" />
<SelectedRowStyle CssClass="SelectedRow" />
<HeaderStyle CssClass="HeaderRow" />
<AlternatingRowStyle CssClass="AlternatingRow" />
------解决方案--------------------
探讨
加个样式试试,希望有用
GridView runat="server" AllowSorting="True"
AutoGenerateColumns="False" CssClass="GridTable"
EmptyDataText="<span style=color:red>未找到符合条件的数据!</span>" EmptyShowHeader="True" HeaderSt……

------解决方案--------------------
添加个空模板
 <EmptyDataTemplate>
<asp:TextBox ID="txtCategoryName" runat="server" />
<asp:Button ID="Btn_AddNewItem" runat="server" CommandName="AddNewItem" Text="Add" />
</EmptyDataTemplate>
------解决方案--------------------
http://www.cnblogs.com/muer/archive/2010/03/26/1697178.html
这里有解决方法
------解决方案--------------------
探讨

引用:
添加个空模板
<EmptyDataTemplate>
<asp:TextBox ID="txtCategoryName" runat="server" />
<asp:Button ID="Btn_AddNewItem" runat="server" CommandName="AddNewItem" Text="Add" />
</Emp……

------解决方案--------------------
<asp:GridView ID="GridView1" runat="server" EmptyDataText="数据为空时照样显示标题" 
Height="205px" Width="535px">
</asp:GridView>
放在EmptyDataText属性里.
------解决方案--------------------
<asp:GridView ID="GridView1" runat="server" EmptyDataText="数据为空时显示标题" 
Height="205px" Width="535px">
</asp:GridView>

------解决方案--------------------
GridView1.HeaderRow.Cells[0].Text = "头部标题";