我有一个 GridView 。如果没有细节,我希望它说“你没有什么可展示的”。
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
但是;它似乎在向后工作,并在 GridView 中显示数据时显示消息,而当 GridView 中没有数据显示时,它仍然是空白页面。
我尝试了以下 IF 语句的各种组合,但没有成功。
最佳答案
相反,请使用 EmptyDataTemplate :
<emptydatatemplate>
No Data Found.
</emptydatatemplate>
关于asp.net GridView IF 空显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9982237/