当我点击gridview中的图像按钮删除行时,我遇到了这个gridview的问题。我有这个代码
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Username" HeaderText="Login Name">
<ItemStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="Question" HeaderText="Question">
<ItemStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="Answer" HeaderText="Answer">
<ItemStyle Width="150px" />
</asp:BoundField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" AutoPostback = "True"
CommandName="Select" ImageUrl="~/images/trash.png" Text="Select" OnClientClick="return confirm('Do you want to delete?');" />
</ItemTemplate>
</asp:TemplateField>
当我点击垃圾图片删除任何行时,它会给我错误。无效的回发或回调参数。 这是我的vb.net代码
Private Sub updatedata(ByVal sql As String)
connectdb()
cmd = New SqlCommand
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = sql
cmd.ExecuteNonQuery()
conn.Close()
End Sub
Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Dim sql4 As String = "delete from login WHERE username='" & GridView1.SelectedRow.Cells(0).Text.Trim() & "' "
updatedata(sql4)
&#13;