Dataview过滤vb.net

时间:2015-11-19 22:12:40

标签: vb.net dataview

想知道我是否正在使用数据视图执行此过滤器,它一直让我犯这个错误

Additional information: Filter expression '80' does not evaluate to a Boolean term.

但这是代码

Dim table = DataSet1.Tables("network")
        table.DefaultView.RowFilter = TextBox1.Text
        DataGridView1.DataSource = table

1 个答案:

答案 0 :(得分:1)

要在DataVIew上过滤某些内容,您需要指定应在其上应用过滤器的列,用于比较的运算符以及要用于过滤的值。您似乎只给出了值“80”。

例如,假设感兴趣的列名为“NumberOfPieces”并且您在文本框中键入了80

Dim table = DataSet1.Tables("network")
table.DefaultView.RowFilter = "NumberOfPieces = " & TextBox1.Text
DataGridView1.DataSource = table

这将过滤视图,其中所有行的值(数值)等于“NumberOfPieces”列中的80。您可以使用其他运算符,例如大/小于(> =< =)或更复杂的构造,这些构造在MSDN页面中详细说明Expression property of the DataColumn object

相关问题