首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

按照grid view 中是否有数据来判断解决思路

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

按照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);
}

热点排行