Check the gridview column check box
<p>I am developing an app in C# in which I am using the datagridview and gridview first column contains the checkboxes and I want to chech the checkbox is true or not but it is giving me the exception of 'Object referernce is not set to an instance of an object'. The code is following</p>

<pre><code>  private void btnDelete_Click(object sender, EventArgs e)
        {
            StudentDAL s = new StudentDAL();

            try 
            {
                for (int i = 0; i &lt; this.dataGridView1.RowCount; i++)
                {

                    if (!DBNull.Value.Equals(this.dataGridView1.Rows[i].Cells[0]) &amp;&amp; (bool)this.dataGridView1.Rows[i].Cells[0].Value == true)
                    {

                        s.delete(Convert.ToInt32(this.dataGridView1.Rows[i].Cells[1].Value));
                        i--;

                    }

                }
                this.dataGridView1.DataSource = s.getAll();

            }
            catch (Exception nn)
            {


            }


        }
</code></pre>

<p>Please help me.</p>
