2011-06-01 103 views
2

在我的应用程序中,我使用DataGrid,我绑定数据集到该DataGrid.So如果数据集记录为零,我想在我的DataGrid中显示“没有ReCORDS FOUND”。DataGrid想要显示没有记录

在此先感谢。

+0

我们可以看到您当前的代码吗? – slandau 2011-06-01 21:09:11

回答

0

您也有GridView标签,因此对于GridView,您可以将它的EmptyDataText属性设置为"No records found"。这与DataGrid有点复杂。

2

有一个DataGrid没有EmptyDataText属性,所以在你的后台代码做一些像

if (dgTest.Items.Count == 0) 
{ 
    lblEmpty.Visible = true; 
    lblEmpty.Text = "Empty"; 
} 

哪里dgTestDataGridlblEmpty的ID是一个占位符的标签。

+1

更好。 if(dgTest.Items.Count <1) { lblEmpty.Visible = true; lblEmpty.Text =“空”; } else { lblEmpty.Visible = false; } – Maxymus 2011-06-02 10:47:22