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

Edited by pyTony: fixed formatting

6 Years
Discussion Span
Last Post by orville

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.

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.