您的位置:首页 > 其它

GridView绑定数据源,无记录时表头也显示的一种解决方法

2007-10-28 22:17 615 查看

public void BuildNoRecords(GridView gridView, DataSet ds)




...{




try ...{




if (ds.Tables(0).Rows.Count == 0) ...{


ds.Tables(0).Rows.Add(ds.Tables(0).NewRow());


gridView.DataSource = ds;


gridView.DataBind();


int columnCount = gridView.Rows(0).Cells.Count;


gridView.Rows(0).Cells.Clear();


gridView.Rows(0).Cells.Add(new TableCell());


gridView.Rows(0).Cells(0).ColumnSpan = columnCount;


gridView.Rows(0).Cells(0).Text = "No Records Found.";


}




} catch (Exception ex) ...{


}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: