title: Gridview Rowcommand Datakey gives index out of range error
body: <p>I have added a button named reserve to my gridview, and when I click it I want do some modification on the gridview, however it gives index out of range error. Below is rowCommand method: </p>
  
  <pre><code>    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
      {
          int index = Convert.ToInt32(e.CommandArgument);
          GridViewRow row = GridView1.Rows[index];
  
          if (row.RowType == DataControlRowType.DataRow)
          {
              welcomeUser.InnerText = GridView1.DataKeys[index].Value.ToString();
          }            
      }
  </code></pre>
  
  <p>Below is my gridview columns:</p>
  
  <pre><code>        &lt;Columns&gt;
              &lt;asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" /&gt;
              &lt;asp:BoundField DataField="BookName" HeaderText="BookName" 
                  SortExpression="BookName" /&gt;
                &lt;asp:ButtonField ButtonType="Button" Text="Reserve" CommandName="Reverse" /&gt;
          &lt;/Columns&gt;
  </code></pre>