IndexOutOfRange/ System.FormatException in Gridview
<p>I have a gridview with checkbox in my codebehind page. The functionality is that I need to select the records to be deleted using checkbox and click the delete button. I use the below code to do that.. But when I select the last row it does not get deleted. Instead it throws IndexOutOfRange/ System.FormatException ..</p>

<p>The error is thrown at this line </p>

<pre><code>  CheckBox chkb = (CheckBox)gvAll.Rows[i].Cells[0].FindControl("chk");


       for (int i = 0; i &lt; count; i++)
         {
             CheckBox chkb = (CheckBox)gvAll.Rows[i].Cells[0].FindControl("chk");
             if (chkb.Checked == true)
             {
                 string name = gvAll.Rows[i].Cells[3].Text;
                 if (!(name.Equals(System.DBNull.Value)))
                 {
                     a.delete(name);
                 }
             }
         }
</code></pre>

<p>It's an urgent issue. Please help..</p>
