在vb.net的后台操作中
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim id As String = GridView1.DataKeys(e.RowIndex).Value.ToString()
Dim row As GridViewRow
For Each row In GridView1.Rows
If row.RowType = DataControlRowType.DataRow Then
Dim tmpid As String '临时ID
tmpid = row.Cells(0).Text '获取第行第1列的值,这要看你的标识列是在第几列
If yhdh = tmpid Then
id .Visible = False
End If
End If
Next
End Sub
在C#中,是同样的原理,操作应该更方便些,貌似只需要要
gridview.Rows.RemoveAt(gridview.CurrentRow.Index);