我想在VB.NET中禁用GridView的特定行。
我试过,但所有行都被禁用了。
For a As Integer = indexSelected To DataGridDefectProduct.Rows.Count - 1
DataGridDefectProduct.Rows(a).Enabled = False
Next
中的错误
DataGridDefectProduct.Rows(a).Enabled = False
请建议是否有其他方法可以做到这一点。
答案 0 :(得分:1)
您必须更改ReadOnly
Row
属性
For a As Integer = indexSelected To DataGridDefectProduct.Rows.Count - 1
DataGridDefectProduct.Rows(a).ReadOnly = False
Next
答案 1 :(得分:0)
但是似乎有启用了gridviewrow的属性
Private Sub gv_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
If Mode = "View" Then
e.Row().Enabled = False
End If
End If
End Sub
这将使该行无法编辑或删除,但允许分页在视图模式下仍然有效