我想获取gridview无数据状态,怎么写啊?
类似于,这个是如果gv的行数为0,就显示无出货,但是不对!!if (GridView1.Rows.Count = 0)
                {
                    Label15.Text = "无出货!";
                }

解决方案 »

  1.   

    if (ds.Tables[0].Rows.Count == 0)
            {
                ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());            GridView1.DataSource = ds;            GridView1.DataBind();            int columnCount = GridView1.Rows[0].Cells.Count;            GridView1.Rows[0].Cells.Clear();            GridView1.Rows[0].Cells.Add(new TableCell());            GridView1.Rows[0].Cells[0].ColumnSpan = columnCount;            GridView1.Rows[0].Cells[0].Text = "没有记录被查询到";            this.GridView1.SelectedIndex = -1;        }
      

  2.   

    if (GridView1.DataSource==null)
                    {
                        Label15.Text = "无出货!";
                    }
      

  3.   

    if (GridView1.Rows.Count < 1)
            {
                Label15.Text = "无出货!";
            }晕,自己又试了下 好了!
      

  4.   


    if (GridView1.Rows.Count == 0)
    {
          Response.Write("<script language='javascript'>alert('aaa')</script>");
    }
    我试了 这样可以啊