asp.net GridView IF空显示消息

use*_*487 2 vb.net asp.net

我有一个网格视图.如果没有细节,我希望它说"你没有什么可展示的".

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound


    If GridView1.Rows.Count = 0 Then
        Lblemptygridview.Text = "you do no details to show"

    Elseif e.Row.RowType = DataControlRowType.DataRow then
        Dim datakey As String = GridView1.DataKeys(e.Row.RowIndex).Value.ToString()

    End If


End Sub
Run Code Online (Sandbox Code Playgroud)

然而; 当网格视图中没有要显示的数据时,它似乎正在向后工作并在网格视图中显示数据时显示消息,并且仍然是空白页面.

我已尝试过以下IF语句的各种组合,但没有成功.

Ica*_*rus 11

相反,使用EmptyDataTemplate:

 <emptydatatemplate>
        No Data Found.  
    </emptydatatemplate> 
Run Code Online (Sandbox Code Playgroud)