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;
6 Years
Discussion Span
Last Post by phoenix911

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


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());

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.