【发布时间】:2011-09-28 16:37:53
【问题描述】:
出于商业目的,我必须禁用我的 gridview 上的所有控件。
Me.gvLineItems.Enabled=False
但是,我需要启用一个超链接字段,所以我尝试了这个:
For Each Row As GridViewRow In Me.gvLineItems.Rows
Dim hrf As HyperLink
hrf = CType(Row.Cells(16).Controls(0), HyperLink)
hrf.Enabled = True
Next
我调试代码并将超链接字段设置为 true,但是当我运行应用程序时,该字段仍然被禁用...
但如果我去掉 Me.gvLineItems.Enabled=False,只需将其注释掉并更改我的代码以禁用超链接字段:
For Each Row As GridViewRow In Me.gvLineItems.Rows
Dim hrf As HyperLink
hrf = CType(Row.Cells(16).Controls(0), HyperLink)
hrf.Enabled = False
Next
这很好用...
但这不是我需要的 :(,只是试图重新启用链接字段...
编辑
我也在 rowdatabound 事件中尝试过这个:
If Me.gvLineItems.Enabled = False Then
For i As Integer = 0 To e.Row.Cells.Count - 1
If TypeOf (e.Row.Cells(i).Controls(0)) Is HyperLink Then
Dim h As HyperLink = CType(e.Row.Cells(i).Controls(0), HyperLink)
h.Enabled = True
Exit For
End If
Next
End If
【问题讨论】: