Client-side confirmation on gridview does not work
<p>In my project, In gridview i want to add a client-side confirtmation for deleting a record. Everything seems right, browser asks for confirmation, after pressing "yes", nothing happens in gridview as well at database. What's the missing point ? Thanks for answers. Also in gridview, after pressing edit button "ArgumentOutOfRangeException was unhandled by user code" exception occurs</p>

<pre><code>&lt;asp:GridView ID="grid1" runat="server" DataSourceID="sqlSource1" DataKeyNames="id"
                AutoGenerateColumns="false" 
                BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" 
                CellPadding="3" ForeColor="Black" GridLines="Vertical" OnRowDataBound="grid1_RowDataBound"&gt;
                    &lt;Columns&gt;
                        &lt;asp:CommandField ShowDeleteButton="true" ButtonType="Image" DeleteImageUrl="~/Images/delete.gif" /&gt;
                        &lt;asp:CommandField ShowSelectButton="true" ButtonType="Image" SelectImageUrl="~/Images/select.gif" /&gt;
                        &lt;asp:CommandField ShowEditButton="true" ButtonType="Image" EditImageUrl="~/Images/edit.gif" UpdateImageUrl="~/Images/update.png" CancelImageUrl="~/Images/delete.gif" CausesValidation="false" /&gt;                        
                        &lt;asp:BoundField DataField="id" HeaderText="Company ID" /&gt;
                        &lt;asp:BoundField DataField="name" HeaderText="Company Name" /&gt;        
                    &lt;/Columns&gt;    
                    &lt;FooterStyle BackColor="#CCCCCC" /&gt;
                    &lt;PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /&gt;
                    &lt;SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /&gt;
                    &lt;HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /&gt;
                    &lt;AlternatingRowStyle BackColor="#CCCCCC" /&gt;
                &lt;/asp:GridView&gt;
</code></pre>

<hr>

<pre><code>protected void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType == DataControlRowType.DataRow)
        {
            ImageButton del = (ImageButton)e.Row.Cells[0].Controls[0];
            del.OnClientClick = "return confirm('Are you sure to delete ? ');";
        }
    }
</code></pre>
