要实现的效果:
用GridView生成了一个数据列表,现在想在没有数据的时候,GridView隐藏。同时GridView的位置出现信息提示:“暂时还没有这类的信息”。请问这样的效果,是不是要:判断数据源是否为空,如果为空“GridView”隐藏,同时含有“提示信息的面板”显示。否则,“提示信息的面板”隐藏,“GridView”显示请问,还有没有其它的实现方式???
用GridView生成了一个数据列表,现在想在没有数据的时候,GridView隐藏。同时GridView的位置出现信息提示:“暂时还没有这类的信息”。请问这样的效果,是不是要:判断数据源是否为空,如果为空“GridView”隐藏,同时含有“提示信息的面板”显示。否则,“提示信息的面板”隐藏,“GridView”显示请问,还有没有其它的实现方式???
解决方案 »
- 苹果浏览器/谷歌浏览器 + asp.net 新窗口打开问题
- 用VS 2005做好了的网站,我想把它放到iis下运行,需要怎么生成?
- ASP.NET:error: 26 - 定位指定的服务器/实例时出错
- 散分~~~~~~~~~~~~~~~!
- 关于repeater中的ImageButton的
- 手头有一套ASP.NET+SQLServer2000开发的系统,如何配置才能让这套系统运行起来?
- asp.netd读取asp写的cookies
- 一个问题,关于FrontPage
- 如何生明动态数组(c#)
- Server.tranfer可以跳转,可是用Response.redirect不成功
- System.Net.Mail 发送邮件:Failure sending mail
- 从datatable导出数据到excel文件过程中出现空值
<td nowrap align="center">标题</td>
<TD noWrap align="center">类型</TD>
<td nowrap align="center">操作</td>
</EmptyDataTemplate>
<EmptyDataRowStyle CssClass="gridheader" /> EmptyDataText="暂没有数据"
EmptyDataRowStyle-HorizontalAlign="center"
EmptyDataRowStyle-Font-Bold="true"
<%
if(ds==null)
{}
%>
<script language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
gridview1.DataSource = null;
gridview1.DataBind();
} protected void btnSet_Click(object sender, EventArgs e)
{
gridview1.DataSource = new string[] { "123" };
gridview1.DataBind();
}
</script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gridview1" runat="server">
<EmptyDataTemplate>
no data...
</EmptyDataTemplate>
</asp:GridView>
</div>
<asp:Button ID="btnSet" runat="server" Text="测试" OnClick="btnSet_Click" />
</form>
</body>
</html>
div2放 提示的话
gridview绑定的时候数据源为空 自然页面就什么也没有
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
if (dt.Rows.Count == 0)
{
this.GridView1.EmptyDataText = "暂时没有数据";
this.GridView1.DataBind();
}
else
{
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
}
再次请问各位大侠,Repeater里可以使用吗?
抱歉,暂时没有数据信息!
</EmptyDataTemplate>
在Repeater里可以使用吗???
当然gv没有值时侯 gv.InnerHtml ="提示消息 " .
可否 ?
{
DataGrid.DataSource = dt;
DataGrid.DataBind();
}
else
{
lbl.Text = "暂时没有数据";
DataGrid.DataSource = dt;
DataGrid.DataBind();
}
<!--GridView有个空模板列,当数据源为空显示-->
<EmptyDataTemplate>
<table>
<tr>
<td>ZZZ</td>
</tr>
</table>
</EmptyDataTemplate>
<!--Repeater可以在FooterTemplate里判断-->
<FooterTemplate>
<%if (Repeater1.Items.Count == 0)
{ %>
<table>
<tr><td>空</td></tr>
</table>
<%} %>
</FooterTemplate>