vb.net 如何禁用 GridView 中的特定行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24901494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable specific rows in GridView
提问by susiana
I want to disable specific rows of GridView in VB.NET.
我想在 VB.NET 中禁用 GridView 的特定行。
I have tried, but all rows got disabled.
我试过了,但所有行都被禁用了。
For a As Integer = indexSelected To DataGridDefectProduct.Rows.Count - 1
DataGridDefectProduct.Rows(a).Enabled = False
Next
error in
错误
DataGridDefectProduct.Rows(a).Enabled = False
DataGridDefectProduct.Rows(a).Enabled = False
Please suggest if there is any alternative ways to do this.
请建议是否有任何其他方法可以做到这一点。
回答by Vivek S.
you have to change the
ReadOnlyproperty of yourRowFor a As Integer = indexSelected To DataGridDefectProduct.Rows.Count - 1 DataGridDefectProduct.Rows(a).ReadOnly = False Next
你必须改变你的
ReadOnly财产RowFor a As Integer = indexSelected To DataGridDefectProduct.Rows.Count - 1 DataGridDefectProduct.Rows(a).ReadOnly = False Next
回答by Mark
There does however appear to be a gridviewrow enabled property
然而,似乎有一个启用 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
This disable the row from editing or deleting but allowed pagination to still work in view mode
这将禁止编辑或删除行,但允许分页在查看模式下仍然有效

