我有一个由文本框和组合框填充的数据集,当用户点击“应用”按钮时,我也会在网格中显示它们。我还有一个链接删除按钮。我想要做的是当我点击删除按钮我要删除该特定记录但我的代码删除它们。
Protected Sub gvPlotFilePaymentVouCherDetail_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gvPlotFilePaymentVouCherDetail.RowDeleting
Dim dsPlotFilePaymentVoucherDetails As DataSet
dsPlotFilePaymentVoucherDetails = Session("dataset")
Dim cid As String = gvPlotFilePaymentVouCherDetail.DataKeys(e.RowIndex).Values(0).ToString
dsPlotFilePaymentVoucherDetails.Tables(0).Rows.Clear()
gvPlotFilePaymentVouCherDetail.DataSource = dsPlotFilePaymentVoucherDetails.Tables(0).DefaultView
gvPlotFilePaymentVouCherDetail.DataBind()
Session("dataset") = dsPlotFilePaymentVoucherDetails
End Sub
这是删除所有记录的方式。
答案 0 :(得分:0)
替换
dsPlotFilePaymentVoucherDetails.Tables(0).Rows.Clear()
与
dsPlotFilePaymentVoucherDetails.Tables(0).Rows.Remove( _
dsPlotFilePaymentVoucherDetails.Tables(0).Select("column_name = '" & cid & "'")(0))
所以它实际上只删除了你想要的行而不是所有的东西......当然要设置合适的' column_name'