title: Index was out of range. Must be non-negative and less than the size of the collection
body: <p>i am having a grid view and when i click page 2 the error given was highlighted at my sql command which is this : <code>SqlCommand cmdShow = new SqlCommand("delete from Student where NRIC= '" + GridView1.DataKeys[0].Value + "'", conn);</code> and state that the error was : <code>Index was out of range. Must be non-negative and less than the size of the collection.
  Parameter name: index</code></p>
  
  <p>thsi is my code : </p>
  
  <pre><code>  protected void GridView1_RowDeleted(Object sender, GridViewCommandEventArgs e)
      {
          SqlConnection conn = new SqlConnection("Data Source=MCDU\\SQLEXPRESS;Initial Catalog=n;Integrated Security=True");
  
          conn.Open();
  
          SqlCommand cmdShow = new SqlCommand("delete from Student where NRIC= '" + GridView1.DataKeys[0].Value + "'", conn);
  
          cmdShow.ExecuteNonQuery();
  
          conn.Close();
  
          Response.Redirect("studentParticulars.aspx");
      }
  </code></pre>