Hey all

I would like to know how can i validate that a record is not in a datagridview.. Im using a textbox to type the names in and by a press of a button the grid gets filtered.. I want a messagebox or justr a message to appear in the name is not there..I have got it right to filter but i want it to tell me that the record was not found.

Please help me..

Here is the code im using..

if (txtSearch.Text == String.Empty)
            MessageBox.Show("Please provide a surname to search for", "Search option", MessageBoxButtons.OK, MessageBoxIcon.Information);
            dgvLearnerAllDetails.DataSource = bl.GetAllSortSearch(txtSearch.Text);
            cmbClassFilter.Text = " ";
            cmbGradeFilter.Text = " ";
            txtNumberOfLearners.Text = dgvLearnerAllDetails.Rows.Count.ToString();

According to your above code.
if your grid has 0 rows, You can use a label control to display message.
Page.RegisterStartupScript to display alert.

The above is just to check if the search button is click it should specify that there is no text been typed in.

The textbox im using is the find a person by surname in a datagridview. It then filters the grid, but what i want is that a message box must appear if the name was not found in the gridview.

Be a part of the DaniWeb community

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