I have a text box through which a "Name"
column of a datagridview
is searched but at run time exception throws Object reference not set to an instance of an object
private void textBox1_TextChanged(object sender, EventArgs e)
{
string searchstring = textBox1.Text;
try
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[1].Value.ToString().Contains(searchstring))
{
Do something
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}