title: The GridView 'PendingRecordsGridview' fired event RowDeleting which wasn't handled
body: <p>I've searched in google there's an easy way to delete a record with confirmation using this code:</p>
  
  <pre><code>&lt;asp:templatefield HeaderText="Delete"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Button ID="deleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this user?');" /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:templatefield&gt;
  </code></pre>
  
  <p>But when i run it and click delete and clicking "yes" to confirm. this error appears: 
  The GridView 'PendingRecordsGridview' fired event RowDeleting which wasn't handled.</p>
  
  <p>Somebody Help me :( i've also tried adding this code ``OnRowDeleting = "PendingRecordsGridview_RowDeleting" but no success! :( </p>
  
  <p>Here's my gridview full code:</p>
  
  <pre><code>&lt;asp:GridView OnPageIndexChanging="PendingRecordsGridview_PageIndexChanging" ID="PendingRecordsGridview" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" OnRowcommand="PendingRecordsGridview_RowCommand" DataSourceID="sd1" BorderStyle="Ridge" BackColor="White" BorderColor="Black" BorderWidth="3px" CellPadding="4" Width="1070px" PageSize="2" AllowPaging="True"&gt;
          &lt;RowStyle ForeColor="#003399" HorizontalAlign="Center" /&gt;
          &lt;Columns&gt;
              &lt;asp:templatefield HeaderText="Accept"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Button CommandArgument='&lt;%# Bind("id") %&gt;' ID="Button1" runat="server" CausesValidation="false" CommandName="accept" Text="Accept" /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Delete"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Button ID="deleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this user?');" /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="ID" SortExpression="ID"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Eval("ID") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label2" runat="server" Text='&lt;%# Bind("ID") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="First Name" SortExpression="FirstName"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("FirstName") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label3" runat="server" Text='&lt;%# Bind("FirstName") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Last Name" SortExpression="LastName"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("LastName") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label4" runat="server" Text='&lt;%# Bind("LastName") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Middle Name" SortExpression="MiddleLastName"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("MiddleName") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label5" runat="server" Text='&lt;%# Bind("MiddleName") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Address" SortExpression="Address"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("Address") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label6" runat="server" Text='&lt;%# Bind("Address") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Gender" SortExpression="Gender"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("Gender") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label7" runat="server" Text='&lt;%# Bind("Gender") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Contact No." SortExpression="ContactNumber"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("ContactNumber") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label18" runat="server" Text='&lt;%# Bind("ContactNumber") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Plate No." SortExpression="PlateNumber"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("PlateNumber") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label19" runat="server" Text='&lt;%# Bind("PlateNumber") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Mobile Color" SortExpression="Color"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("Color") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label11" runat="server" Text='&lt;%# Bind("Color") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Brand" SortExpression="Brand"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("Brand") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label12" runat="server" Text='&lt;%# Bind("Brand") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:templatefield HeaderText="Liscenced No." SortExpression="LiscensedNumber"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("LiscensedNumber") %&gt;'&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label10" runat="server" Text='&lt;%# Bind("LiscensedNumber") %&gt;'&gt;
                      &lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:templatefield&gt;
              &lt;asp:TemplateField&gt;
              &lt;HeaderTemplate&gt;Image&lt;/HeaderTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;img src='data:image/jpg;base64,&lt;%# Eval("Image") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("Image")) : string.Empty %&gt;' alt="image" height="85" width="85"/&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;        &lt;/Columns&gt;
          &lt;FooterStyle BackColor="#99CCCC" ForeColor="#003399" /&gt;
          &lt;PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="#003399" /&gt;
          &lt;EmptyDataTemplate&gt;
              NO PENDING REQUEST!
          &lt;/EmptyDataTemplate&gt;
          &lt;SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" /&gt;
          &lt;HeaderStyle BackColor="#999999" Font-Bold="True" ForeColor="#003399" HorizontalAlign="Center" /&gt;
          &lt;AlternatingRowStyle BorderColor="Black" BorderWidth="3px" BorderStyle="Ridge" /&gt;
      &lt;/asp:GridView&gt;
          &lt;/td&gt;
          &lt;td style="height: 282px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td style="height: 37px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td valign="top"&gt;
  &lt;asp:SqlDataSource runat="server" id="sd1" ProviderName="&lt;%$ ConnectionStrings:ConnectionString.ProviderName %&gt;" ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" SelectCommand="SELECT * FROM [PendingRecords]" DeleteCommand="DELETE FROM [PendingRecords] WHERE [ID] = ?" InsertCommand="INSERT INTO [PendingRecords] ([Username], [Password], [FirstName], [LastName], [MiddleName], [Address], [Gender], [ContactNumber], [PlateNumber], [Color], [Brand], [LiscensedNumber]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [PendingRecords] SET [Username] = ?, [Password] = ?, [FirstName] = ?, [LastName] = ?, [MiddleName] = ?, [Address] = ?, [Gender] = ?, [ContactNumber] = ?, [PlateNumber] = ?, [Color] = ?, [Brand] = ?, [LiscensedNumber] = ? WHERE [ID] = ?"&gt;
      &lt;DeleteParameters&gt;
          &lt;asp:parameter Name="ID" Type="Int32" /&gt;
      &lt;/DeleteParameters&gt;
      &lt;UpdateParameters&gt;
          &lt;asp:parameter Name="Username" Type="String" /&gt;
          &lt;asp:parameter Name="Password" Type="String" /&gt;
          &lt;asp:parameter Name="FirstName" Type="String" /&gt;
          &lt;asp:parameter Name="LastName" Type="String" /&gt;
          &lt;asp:parameter Name="MiddleName" Type="String" /&gt;
          &lt;asp:parameter Name="Address" Type="String" /&gt;
          &lt;asp:parameter Name="Gender" Type="String" /&gt;
          &lt;asp:parameter Name="ContactNumber" Type="String" /&gt;
          &lt;asp:parameter Name="PlateNumber" Type="String" /&gt;
          &lt;asp:parameter Name="Color" Type="String" /&gt;
          &lt;asp:parameter Name="Brand" Type="String" /&gt;
          &lt;asp:parameter Name="LiscensedNumber" Type="String" /&gt;
          &lt;asp:parameter Name="ID" Type="Int32" /&gt;
      &lt;/UpdateParameters&gt;
      &lt;InsertParameters&gt;
          &lt;asp:parameter Name="Username" Type="String" /&gt;
          &lt;asp:parameter Name="Password" Type="String" /&gt;
          &lt;asp:parameter Name="FirstName" Type="String" /&gt;
          &lt;asp:parameter Name="LastName" Type="String" /&gt;
          &lt;asp:parameter Name="MiddleName" Type="String" /&gt;
          &lt;asp:parameter Name="Address" Type="String" /&gt;
          &lt;asp:parameter Name="Gender" Type="String" /&gt;
          &lt;asp:parameter Name="ContactNumber" Type="String" /&gt;
          &lt;asp:parameter Name="PlateNumber" Type="String" /&gt;
          &lt;asp:parameter Name="Color" Type="String" /&gt;
          &lt;asp:parameter Name="Brand" Type="String" /&gt;
          &lt;asp:parameter Name="LiscensedNumber" Type="String" /&gt;
      &lt;/InsertParameters&gt;
  &lt;/asp:SqlDataSource&gt;
          &lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td style="height: 33px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style="width: 32px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td style="width: 8px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td style="width: 87px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td style="width: 542px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td style="width: 447px"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td style="height: 83px; width: 34px;"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>