asp.net的GridView中频空洞的表演消息 [英] asp.net GridView IF empty show message

查看:95
本文介绍了asp.net的GridView中频空洞的表演消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图。我希望它说:你有什么可显示如果没有细节。

I've got a grid view. I want it to say "you have nothing to show" if there are no details.

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

不过,它似乎是倒退的工作,并显示该消息时,有数据在网格视图中显示,并仍然是一个空白页时,没有数据网格视图中显示。

However; it seems to be working backwards and showing the message when there is data to display in the gird view and continues to be a blank page when there is not data to display in the grid view.

我已经尝试了多种组合与下面的IF语句以下,但没有成功。

I've tried a variety of combinations with the below IF statement below but no success.

推荐答案

相反,使用EmptyDataTemplate:

 <emptydatatemplate>
        No Data Found.  
    </emptydatatemplate> 

这篇关于asp.net的GridView中频空洞的表演消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆