如果搜索结果为零,如何显示没有找到的数据 [英] How to display no data found if search turned zero results
本文介绍了如果搜索结果为零,如何显示没有找到的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只能搜索数据。如何显示没有找到数据?
我尝试过:
Private Sub SearchToolStripMenuItem_Click(sender As Object,e As EventArgs)Handles SearchToolStripMenuItem.Click
Dim DV As New DataView(dbDataSet)
DV.RowFilter = String.Format (ear_number like'%{0}%',TextBox1.Text)
DataGridView2.DataSource = DV
End Sub
解决方案
您可以使用DataView.Count属性 - DataView.Count属性(System.Data)| Microsoft Docs [ ^ ]如果它返回0,则将No Data Found文本放入DataGridView2
的第一列,否则设置数据源
i can only search data. how to display no data found?
What I have tried:
Private Sub SearchToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SearchToolStripMenuItem.Click Dim DV As New DataView(dbDataSet) DV.RowFilter = String.Format("ear_number Like '%{0}%'", TextBox1.Text) DataGridView2.DataSource = DV End Sub
解决方案
You could use the DataView.Count property - DataView.Count Property (System.Data) | Microsoft Docs[^] If it returns 0 then put your "No Data Found" text into the first Column ofDataGridView2
otherwise set theDataSource
这篇关于如果搜索结果为零,如何显示没有找到的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文