2011-06-01 115 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

相關問題