Protected Sub GrdCodes_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles grdCodes.ItemDataBound
Try
If (TypeOf e.Item Is GridDataItem) Then
Dim item = DirectCast(e.Item, GridDataItem)
Dim btnDelete = DirectCast(item("DeleteColumn").Controls(0), LinkButton)
Dim btnEdit = DirectCast(item("EditColumn").Controls(0), LinkButton)
btnDelete.Visible = HasRights()
btnEdit.Visible = HasRights()
End If
If (TypeOf e.Item Is GridEditableItem AndAlso DirectCast(e.Item, GridEditableItem).IsInEditMode) AndAlso Not TypeOf e.Item.DataItem Is GridInsertionObject Then
Dim editedItem = DirectCast(e.Item, GridEditableItem)
Dim txtBc = DirectCast(e.Item.FindControl("Barcode").Controls(0), TextBox)
txtBc.Enabled = False
End If
Catch ex As Exception
Logger.WriteToLog(LoggingBase.eLoggingSeverity.eErrorSeverity, "GrdCodes_ItemDataBound failed", ex, Now)
End Try
End Sub
txtBc.Enabled错误= False,未设置对象引用错误
我们需要在编辑模式下禁用特定的文本框 但失败并捕获了异常