You must Sign In to post a response.
  • Category: Windows

    Check cell value in datagridview

    how to check available name in datagridview cell value.

    this code not working:
    --------------

    private void button1_Click(object sender, EventArgs e)
    {
    string dd = "srini";

    if (dataGridView1.Rows[0].Cells["numRows"].Value == dd)
    {
    MessageBox.Show("No available in first row");
    }
    }
  • #459222
    Try this
    dataGridView1.Rows[0].Cells[column index].Value instead of
    dataGridView1.Rows[0].Cells["numRows"].Value

  • #459225
    its not working lalitha lavanya

  • #459228
    string dd = "srini";
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
    if (GridView1.Rows[i].Cells[0].Text==dd)
    {
    MessageBox.Show("No available in first row");
    }
    }

    I have tested it.
    Working fine.

  • #459230
    hi lalitha i got this error : i could n't solve this ma

    Error 1 'System.Windows.Forms.DataGridViewCell' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'System.Windows.Forms.DataGridViewCell' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\spider\Local Settings\Application Data\Temporary Projects\datagridd\Form1.cs 37 52 datagridd

  • #459231
    for (int i = 0; i < dataGridView1.Rows.Count; i++)
    {
    if (dataGridView1.Rows[i].Cells[0].Value.ToString() == dd)
    {
    MessageBox.Show("No available in first row");
    }
    }

    sorry I have tested in web application.


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.