title: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
body: <p>When i am click on update button i got this error 
  my update click event </p>
  
  <pre><code>protected void btnUpdate_Click(object sender, CommandEventArgs e)
  {
      int idx = Convert.ToInt32(e.CommandArgument);
      GridViewRow gr = gvResTasks.Rows[idx];
      ...
  }
  </code></pre>
  
  <p>when  idx value is upto 19 it works fine ..when it is greater than 19 this error came..
  could you please help me on this</p>
  
  <p>Updatebutton.aspx</p>
  
  <pre><code>&lt;ItemTemplate&gt; &lt;asp:Button runat="server" ID="btnUpdate" Text="Update" OnCommand="btnUpdate_Click" CommandArgument="&lt;%# Container.DataItemIndex %&gt;" /&gt; &lt;%--&lt;asp:Button runat="server" ID="Button1" Text="Update" onclick="btnUpdate_Click" /&gt;--%&gt; &lt;/ItemTemplate&gt;    
  </code></pre>
  
  <p>updatebutton.aspx.cs</p>
  
  <pre><code>protected void btnUpdate_Click(object sender, CommandEventArgs e)
  {
     // int idx = Convert.ToInt32(e.CommandArgument);
      int idx = Convert.ToInt32(e.CommandArgument);
      GridViewRow gr = gvResTasks.Rows[idx];
  
      Label hf = (Label)gr.FindControl("hdEmployeeID");
  
      string sEmpID = hf.Text;
      lblEmployeeID.Text = sEmpID;
      lblEmployeeID2.Text = sEmpID;
  
      int Rows = gvResTasks.Rows.Count;
      for (int x = 0; x &lt; Rows; x++)
      {
          GridViewRow tr = gvResTasks.Rows[x];
          tr.CssClass = "WhiteBack";
      }
  
      ClearMessages();
  
      gr.CssClass = "TealBack";
  
      string sSubTaskID = gr.Cells[0].Text;
      lblSubTaskID.Text = sSubTaskID;
  
      lblSubTaskName.Text = @gr.Cells[1].Text;
  
      LoadSubTaskInfo();
  
      Single sProgress = 0;
      Boolean bok = Single.TryParse(lblActualProgress.Text, out sProgress);
  
  
  
  
      DateTime dPF = DateTime.Parse(lblPlannedFinish.Text);
  
      if (dPF &gt; DateTime.Now)
      {
          btnFinish.Enabled = false;
      }
      else if (dPF &lt;= DateTime.Now)
      {
          if (sProgress &gt;= 100)
          {
              btnFinish.Enabled = false;
          }
          else
          {
              btnFinish.Enabled = true;
          }
          //btnFinish.Enabled = true;
      }
  
      panelUpdate.CssClass = "float";
      panelUpdate.Visible = false;
      if (gr.Cells[7].Text != "True")
      {
          panelUpdate.Visible = true;
      }
  
  
  }
  </code></pre>