日期:2014-05-20  浏览次数:20452 次

控件查询无数据的提示问题
img=C:\Users\ThinkPad\Desktop][QQ截图20111024095713/img]  
protected void Button1_Click(object sender, EventArgs e)
  {
  string str = "Data Source=172.18.1.12,1533;Persist Security Info=True;Password=adminbbxsqlweb;User ID=sa;Initial Catalog=IV_ScmDB";
  SqlConnection myConnection = new SqlConnection(str);
  myConnection.Open();
  SqlCommand myCommand = new SqlCommand("select goodsid 商品编码,favprice 优惠价,startdate 优惠开始日期,enddate 优惠结束日期,regdate 登记日期,regoper 登记人 from Bas_GoodsDeptFav where departid='" + DropDownList1.Text.Trim() + "' and Convert(VarChar(10), enddate, 20) ='" + datekj.Value.Trim() + "'", myConnection);
  SqlDataAdapter Adapter = new SqlDataAdapter();
  Adapter.SelectCommand = myCommand;
  DataSet myDs = new DataSet();
  Adapter.Fill(myDs);
  DataGrid1.DataSource = myDs;
  DataGrid1.DataBind();
  myConnection.Close();
  }
请教如何实现如果查询无结果,在DataGrid就显示一行文字提示呢

------解决方案--------------------
如果没文字,可以自己添加一个row,然后写上自己的文字