filtering multiple fields

jberger

Member
Joined
May 10, 2007
Messages
11
Location
Illinois
Programming Experience
Beginner
I'm trying to filter by multiple fields. When I enter the criteria, it just gives me what's in the 'EmployeeBox'. Here's the line where I'm doing the filtering:
VB.NET:
dv.RowFilter = "sender = '" & Trim(SenderBox.Text) & "'" & "Employee_Name = '" & Trim(EmployeeBox.Text) & "'"
Please help.
 
When you debug what does the RowFilter string look like?
If SenderBox.Text="sender" and EmployeeBox.Text = "employee" then
dv.RowFilter="sender = 'sender' Employee_Name = 'employee'".
It should be "sender = 'sender' AND Employee_Name = 'employee'"
 
I'm trying to filter by multiple fields. When I enter the criteria, it just gives me what's in the 'EmployeeBox'. Here's the line where I'm doing the filtering:
VB.NET:
dv.RowFilter = "sender = '" & Trim(SenderBox.Text) & "'" & "Employee_Name = '" & Trim(EmployeeBox.Text) & "'"
Please help.

You can help yourself by making your code more readable. Use string.Format instead of multiple string concats

dr.RowFilter = String.Format("Sender = '{0}' AND Employee = '{1}' ", sender.Text, employee.Text)
 
Back
Top