Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Search datagrid from two textbox c#

How to add SearchTextBox2.Text to search value from 2 textbox in EmailDataGridView?

What I have tried:

C#
(EmailDataGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("[Ime i prezime] LIKE '%{0}%' OR [Preduzece] LIKE '%{0}%'  OR [E-mail] LIKE '%{0}%' ", SearchTextBox.Text);
Posted
Updated 25-Oct-21 15:02pm
v2
Comments
BillWoodruff 20-Sep-21 11:13am    
I only see use of one TextBox.
Goran Bibic 21-Sep-21 2:04am    
Ok. How to repair code? I try this but dont work, search just datagrid from 1 textbox

(EmailDataGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("[Ime i prezime] LIKE '%{0}%' OR [Preduzece] LIKE '%{0}%' OR [E-mail] LIKE '%{0}%' ", SearchTextBox.Text + SearchTextBox2.Text);
BillWoodruff 21-Sep-21 2:15am    
Hi, i can't help you unless you explain what you are trying to do in much more detail. i can't read your mind.
Goran Bibic 21-Sep-21 2:16am    
Search datagrid from textbox
BillWoodruff 21-Sep-21 3:17am    
your repeating the same vague statement will not enable us to help yoi.

1 solution

I believe you're looking for "IN"

(EmailDataGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("[Ime i prezime] IN ('{0}', '{1}') OR [Preduzece] IN ('{0}', '{1}') OR [E-mail] IN ('{0}', '{1}') ", SearchTextBox.Text, SearchTextBox2.Text);
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900