Hi,
I have 4 searchbox and with them i can search in a Datagridview.
But the problem is that they are not connected to each other. So what I want is that they are connected to each other.

If i search in 'firstname' then the firstname displays but when I search in 'last name' then I want it to show the 'first name' and display the last name is had entered earlier.


This is the code i have used to search in datagridview.

DataView Dv = new DataView();

            Dv.Table = partsDataSet.Tables["parttable"];
            Dv.RowFilter = " Model LIKE '%" + modelSearchBox.Text + "%' ";
            dataGridView1.DataSource = Dv;

do you want to search for more than 1 field at a time?

or

search one field, and all relevant data with that ( this should already be happening0

>So what I want is that they are connected to each other.

Please be more specific. I guess you have to use and operator.

List<string> query = new List<string>();
    
    if (txtSearch1.Text.Length != 0)
        query.Add("firstname like '" + txtSearch1.Text + "%'");
    if (txtSearch2.Text.Length != 0)
        query.Add("middlename like '" + txtSearch2.Text + "%'");
    if (txtSearch3.Text.Length != 0)
        query.Add("lastname like '" + txtSearch3.Text + "%'");

     string queryResult = string.Join(" and ", query.ToArray());
 
     Dv.RowFilter=queryResult;

the above code, would work, if thats what you wanted, but like he mentioned, you have to be more specific, I myself wasnt to sure what you meant, thats why i asked

if you wanted to search multiple fields at once, good post adatapost

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.