title: Updating GridView row on button click
body: <p>I have a GridView which contains a Link Button inside a Template Field. The code is shown below:</p>
  
  <pre><code>&lt;asp:GridView ID="gv1" runat="server" AutoGenerateColumns="False"
      DataSourceID="SqlDataSource1" onrowediting="gv1_RowEditing"
          onrowcommand="gv1_RowCommand"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="inDetailsId" HeaderText="inDetailsId"
                  SortExpression="inDetailsId" /&gt;
              &lt;asp:BoundField DataField="inUserId" HeaderText="inUserId"
                  SortExpression="inUserId" /&gt;
              &lt;asp:TemplateField&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:LinkButton ID="lnk1" runat="server" Text='&lt;%# Eval("attDate")%&gt;' CommandName="Edit"&gt;&lt;/asp:LinkButton&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:BoundField DataField="attstatus" HeaderText="attstatus"
                  SortExpression="attstatus" /&gt;
              &lt;asp:BoundField DataField="inAttendanceStatusId"
                  HeaderText="inAttendanceStatusId" SortExpression="inAttendanceStatusId" /&gt;
          &lt;/Columns&gt;
  
      &lt;/asp:GridView&gt;
      &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server"
      ConnectionString="&lt;%$ ConnectionStrings:LearnConnectionString %&gt;"
      SelectCommand="SELECT * FROM [attendance]"&gt;&lt;/asp:SqlDataSource&gt;
      &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
  </code></pre>
  
  <p>The code-behind is below:</p>
  
  <pre><code> protected void gv1_RowCommand(object sender, GridViewCommandEventArgs e)
          {
              gv1.EditIndex = 1;
          }
  </code></pre>
  
  <p>On clicking the Link Button, I am setting GridView Edit Index to 1 to make the row editable.</p>
  
  <p>Now I want to save the updated row. On Click of another button on the Web Page, I want to save the updated changes and change the row edit mode to non-editable mode.</p>