日期:2014-05-18  浏览次数:20404 次

按照grid view 中是否有数据来判断
label1,gridview1。
如何让gridview1中有数据时候label1显示‘数据’。
没有数据时候不显示?

------解决方案--------------------
根据数据源来判断到底有没有数据,我想是很容易的。
如数据源是DataTable
则DataTable.Rows.count> 0时,表示有数据。
------解决方案--------------------
this.Label1.Text = "数据 ";
this.Label1.Visible = (this.GridView1.Rows.Count > 0);
------解决方案--------------------
protected void Button1_Click(object sender, EventArgs e)
{
PostBackOptions myPostBackOptions = new PostBackOptions(this);

this.GridView1.DataSource = GetMyDataSource();
this.GridView1.DataBind();

this.Label1.Text = "数据 ";
this.Label1.Visible = (this.GridView1.Rows.Count > 0);
}