简单语法错误空检查数据表/gridview asp.net vb

发布于 2024-09-02 13:05:42 字数 870 浏览 3 评论 0原文

我有这个代码:

Dim Result As New DataTable
DataAdapter.Fill(Result)


            'bind data to visible surname/name grid
            If Result.Rows.Count = 0 Then
                NoInputBottom.Text = "No Results. Please widen your search criteria and try again"
                NoInputTop.Text = "No Results. Please widen your search criteria and try again"
            Else
                GV.DataSource = Result
                GV.DataBind()
            End If

我还尝试将检查移动到网格视图,如下所示:

If GV.Columns.Count = 0 Then
                NoInputBottom.Text = "No Options Selected: Please select your search criteria and try again"
                NoInputTop.Text = "No Options Selected: Please select your search criteria and try again"
            End If

当我运行代码时。 noinput 标签没有值,空检查似乎失败了?如果搜索没有返回结果,请告诉我如何显示消息。

I have this code:

Dim Result As New DataTable
DataAdapter.Fill(Result)


            'bind data to visible surname/name grid
            If Result.Rows.Count = 0 Then
                NoInputBottom.Text = "No Results. Please widen your search criteria and try again"
                NoInputTop.Text = "No Results. Please widen your search criteria and try again"
            Else
                GV.DataSource = Result
                GV.DataBind()
            End If

I have also tried moving the check to the gridview like so:

If GV.Columns.Count = 0 Then
                NoInputBottom.Text = "No Options Selected: Please select your search criteria and try again"
                NoInputTop.Text = "No Options Selected: Please select your search criteria and try again"
            End If

When I run the code. the noinput labels do not have value, the null check seems to be failing? Please can you tell me how to display a message if the search returned no reults.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残花月 2024-09-09 13:05:42

这是我对原始问题的评论的副本,以便能够将问题标记为已回答(谢谢菲尔)。

调试器说什么
Result.Rows.Count(如果您将鼠标悬停在
鼠标光标放在上面)?这应该
给你带来关于似乎的确定性
失败了,不是吗?我的意思是你知道了
如果 Count 确实不为零(对于
无论什么原因)或者如果文本中
标签(或任何 NoInputBottom
稍后会被覆盖或其他什么
类似。


This is a copy of my comment to the original question in order to be able to mark the question as answered (thank you Phil).

What does the debugger say about
Result.Rows.Count (if you hover your
mouse cursor over it)? This should
bring you certainty about the seems to
be failing
, no? I mean you know then
if Count is indeed not zero (for
whatever reason) or if the text in the
Labels (or whatever NoInputBottom is)
gets overwritten later on or something
similar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文