Note that there are some explanatory texts on larger screens.

plurals
  1. POGridView ImageButton confirm and delete record
    primarykey
    data
    text
    <p>I've got a huge problem here. I've managed to add javascript to my server side, but the problem it is not deleting. It doesnt have produce any errors so I don't know where to start:</p> <pre><code>Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand If e.CommandName = "cmdDelete" Then Dim ID As Integer = Convert.ToInt32(e.CommandArgument) End If End Sub Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim l As ImageButton = DirectCast(e.Row.FindControl("ImageDelete"), ImageButton) l.Attributes.Add("onclick", "javascript:return " &amp; "confirm('Are you sure you want to delete this record " &amp; DataBinder.Eval(e.Row.DataItem, "ID") &amp; "')") End If End Sub Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting Dim ID As Integer = CInt(GridView1.DataKeys(e.RowIndex).Value) 'dim ID as Integer con.Open() 'gridview1.rows(e.rowindex).cells(0) Dim cmd As New SqlCommand("delete from [tblUser] where [ID]=@ID", con) cmd.Parameters.AddWithValue("@ID", ID) cmd.ExecuteNonQuery() con.Close() End Sub </code></pre> <p>Client side</p> <pre><code> &lt;asp:TemplateField HeaderText="Delete"&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton ID="ImageDelete" ImageUrl="" runat="server" CommandName="cmdDelete" CommandArgument='&lt;%# Eval("ID") %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload