当DATAGRID通过数据库得到一个空的结果时候,我想给页写一句话: 没有查到相关结果. 该怎么写?
解决方案 »
- 二级导航中地址栏传参错误!!!!!!!!!!
- csdn史上未解决的DSOframer问题
- 高分求助:先装的VS2005,又安装的SQL2000,最后安装的SQL2005,为何数据库不可用?
- 无数据也要显示品名,但后面得其他数据为空也可?如何实现?新手提问
- 来看看 iframe 的js传值给 FCKeditor 问题
- 请问 Page.RegisterStartupScript 为什么不起作用?
- 新手学习ASP.NET的疑问?
- 模版列里如何显示数据呢?
- 请解述 Web窗体,移动Web窗体,Web用户控件,移动Web用户控件 的区别与用处?
- 关于画图
- VS2005里有没有比较简单的“写”XML文件的方法?
- 解析XML,急急急~~~~
数据库写法如下:
string dbname;
dbname=Server.MapPath("lpan.mdb");
myConnection = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" + dbname );
myConnection.Open();
myCommand = new OleDbCommand( "select lpmc FROM lpan where lpmc like '%"+lpmc1+"%'", myConnection );
DataGrid1.DataSource=myCommand.ExecuteReader();
DataGrid1.DataBind(); myConnection.Close();
or
在DataGrid1下面放一个Label
load 中
this.Label.Visible=false;if(this.DataSet.Table[0].Rows.Count=0)
{
this.Label.Visible=true;
this.Label.Text="............";
}
else
{}
if(this.DataSet.Table[0].Rows.Count=0)
"="改为"=="呵呵
c:\inetpub\wwwroot\loupan\chaxun.aspx.cs(96): “loupan.chaxun”并不包含对“DataSet”的定义
该如何定义DataSet???没用过DataSet.
--------------------------------------------------------------------------------无法找到表 0。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IndexOutOfRangeException: 无法找到表 0。源错误:
行 95:
行 96:
行 97: if(ds.Tables[0].Rows.Count==0)
行 98: {
行 99: this.DataGrid1.Columns[0].HeaderText="没有查到你想要的结果";
myConnection = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" + dbname );
myConnection.Open();
myCommand = new OleDbCommand( "select lpmc FROM lpan where lpmc like '%"+lpmc1+"%'", myConnection );
if(!myCommand.ExecuteReader())
{
this.Label.Visible=true;
this.Label.Text="............";
} DataGrid1.DataSource=myCommand.ExecuteReader();
DataGrid1.DataBind(); myConnection.Close();
if(ds.Tables.Count == 0 || (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count==0))
{
//没有结果
}
if(ds.Tables.Count == 0 || (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count==0))
{
//没有结果
}
无论有没有 都是一样的结果