title: Updating gridview row is not saving the data
body: <p>I am having issue when updating gridview! everything is seems to be working. but when i hit finish editing the data will not save!</p>
  
  <p>but when i click edit the correct fields prompt me to enter new value but it wont save!</p>
  
  <p>here is my asp</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" CssClass="report" 
      AutoGenerateColumns="False" onrowediting="GridView1_RowEditing" 
      DataKeyNames="TimeID" onrowupdating="GridView1_RowUpdating" 
      onrowcommand="GridView1_RowCommand" 
      onrowcancelingedit="GridView1_RowCancelingEdit"&gt;
  
      &lt;Columns&gt; 
  
  
  
          &lt;asp:BoundField DataField="date" Visible="true" ReadOnly="true" HeaderText="Date" /&gt;
          &lt;asp:BoundField DataField="Description" HeaderText="Stage Description" ReadOnly="True" /&gt;
  
  
         &lt;asp:TemplateField HeaderText="Start Time"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label7" runat="server"  Text='&lt;%# ConvertToShotTime(Eval("StartTime")) %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:TextBox ID="txtStartTime" ValidationGroup="1" Width="90px"  class="TimeEntry" runat="server"  Text='&lt;%# ConvertToShotTime(Eval("StartTime")) %&gt;'&gt;&lt;/asp:TextBox&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="txtStartTime" runat="server" ErrorMessage="RequiredFieldValidator"&gt;&lt;/asp:RequiredFieldValidator&gt;
             &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
  
  
  
          &lt;asp:TemplateField HeaderText="End Time"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label1" runat="server"  Text='&lt;%# ConvertToShotTime(Eval("EndTime")) %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:TextBox ID="txtEndTime" class="TimeEntry"  ValidationGroup="1" Width="90px" runat="server"  Text='&lt;%# ConvertToShotTime(Eval("EndTime")) %&gt;'&gt;&lt;/asp:TextBox&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator66" ControlToValidate="txtEndTime" runat="server" ErrorMessage="RequiredFieldValidator"&gt;&lt;/asp:RequiredFieldValidator&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
  
  
          &lt;asp:BoundField DataField="TimeInHours" HeaderText="Time Time (Hours)" ReadOnly="True" /&gt;
  
          &lt;asp:CommandField ShowEditButton="true" ShowCancelButton="true" 
              ButtonType="Image" EditImageUrl="~/images/edit_record.jpg" 
              CancelImageUrl="~/images/edit_no.jpg" 
              UpdateImageUrl="~/images/update_record.jpg" /&gt;
  
          &lt;asp:TemplateField ShowHeader="False"&gt;
              &lt;ItemTemplate&gt;
                &lt;asp:ImageButton ID="lnbCopy" runat="server" AlternateText="Delete" 
                      CommandName="DeleteRecord"  CommandArgument='&lt;%# Bind("TimeID") %&gt;'  OnClientClick="return confirm('Are you sure you want to delete this row?');"  ImageUrl="~/images/delete_record.jpg" /&gt;
              &lt;/ItemTemplate&gt;
  
             &lt;EditItemTemplate&gt;
                  &lt;asp:Label ID="lblTimeID" runat="server" Text='&lt;%# Eval("TimeID") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
  
  
  
  
  
  
  
  
      &lt;/Columns&gt;
  
  
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>here is what i have done in behind code</p>
  
  <pre><code>protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) {
      GridView1.EditIndex = e.NewEditIndex;
      loadTable();
  }
  
  protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) {
      GridView1.EditIndex = -1;
      loadTable();
  }
  
  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) {
  
      GridViewRow row = GridView1.Rows[e.RowIndex] as GridViewRow;
  
  
      var StartTime = row.FindControl("txtStartTime") as TextBox;
      var EndTime = row.FindControl("txtEndTime") as TextBox;
      var id = row.FindControl("lblTimeID") as Label;
  
      SqlConnection conn = new SqlConnection(conStr.GetConnectionString("myServer1"));
  
      SqlCommand comm = new SqlCommand();
  
      comm.CommandText = "UPDATE CDSTimeSheet SET StartTime = @StartTime, EndTime = @EndTime ,timeElapsed = datediff(minute,@startTime , @EndTime), timeInSeconds = datediff(second,@startTime , @EndTime) WHERE TimeID = @id";
      comm.Connection = conn;
  
      comm.Parameters.AddWithValue("@id", id.Text);
      comm.Parameters.AddWithValue("@StartTime", StartTime.Text);
      comm.Parameters.AddWithValue("@EndTime", EndTime.Text);
  
      conn.Open();
      comm.ExecuteNonQuery();
      conn.Close();
      GridView1.EditIndex = -1;
      loadTable();
  }
  </code></pre>
  
  <p>what am i doing wrong?</p>