狐爸: 您好! 我换了一种思路 写昨天的代码 ,代码换成了下边的 ,现在 第一个文本框输入过滤加载正常, 第二个文本框 不输入内容时,就是执行第一文本框的代码也正常,若输入第二个文本框内容时 ,加载内容就变成了 空白, 请纠正下代码,谢谢 !
Dim filter1 As String
Dim txt1 As String = e.Form.Controls("TextBox1").text
If txt1 = ""
filter1 = ""
Else
txt1 = "%" & txt1 & "%"
Dim name1 As String
Dim dr1 As DataRow = DataTables("数据位置").find("[表名] = '货品管理' and [控件名] = '默认列1'")
If dr1 IsNot Nothing Then
name1 = dr1("信息跟踪")
filter1 = name1 & " like '" & txt1 & "'"
End If
End If
DataTables("货品管理").LoadFilter = Filter1
DataTables("货品管理").Load()
Dim filter2 As String
Dim txt2 As String = e.Form.Controls("TextBox2").text
If txt2 = ""
filter2 = filter1
Else
txt2 = "%" & txt2 & "%"
Dim name2 As String
Dim dr2 As DataRow = DataTables("数据位置").find("[表名] = '货品管理' and [控件名] = '默认列1'")
If dr2 IsNot Nothing Then
name2 = dr2("信息跟踪")
filter2 = name2 & " Like '" & txt2 & "'"
End If
filter2 = filter2 & " And " & filter1
End If
DataTables("货品管理").LoadFilter = Filter2
DataTables("货品管理").Load()
尤其是 合成 filter2 = filter2 & " and " & filter1 这句, 谢谢狐爸!