<form id="Form1" method="post" runat="server"> <FONT face="宋体"></FONT> <asp:datagrid id="mydatagrid" DataKeyField="id" AutoGenerateColumns="False" Runat="server"> <Columns> <asp:boundcolumn datafield="id" readonly="true" headertext="编号" /> <asp:boundcolumn datafield="name" readonly="true" headertext="姓名" /> <asp:buttoncolumn commandname="delete" text="删除" headertext="命令" /> </Columns> </asp:datagrid></form>
Private Sub mydatagrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles mydatagrid.ItemCommand Dim i As String i = mydatagrid.DataKeys.Item(e.Item.ItemIndex)
If e.CommandName = "delete" Then
com.Connection = SqlConnection1 SqlConnection1.Open() adp.SelectCommand = com com.CommandText = "delete * from table1 where id='" + i + "'" com.ExecuteNonQuery() SqlConnection1.Close()
getdata()
mydatagrid.EditItemIndex = -1
End If End Sub 谁知道哪里错了。怎么不响应呢 ,就是删除不掉一条数据