I've got a RadGrid with a GridAttachmentColumn named "FileName". I'm trying to get (FindControl) the control out of the GridDataItem in the ItemCreated event. Specifically, I want the button control (or linkButton in this case). item.FindControl("FileName") always returns Nothing.
Protected Sub AttachmentsRadGrid_ItemCreated(sender As Object, e As GridItemEventArgs)
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
If item IsNot Nothing Then
Dim FileName = item.FindControl("FileName") 'Always Nothing
If FileName IsNot Nothing Then
'Do something with it
End If
End If
End If
End Sub
Dim button As LinkButton = TryCast(item("FileName").Controls(0), LinkButton)
OR
Dim FileName = item.FindControl("gac_FileName")
The first line of code might be Telerik's preference so I put that line first. Notice that the AttachmentColumn in read mode is basically just a linkbutton.
Notice in the 2nd example that "gac_" in item.FindControl("gac_FileName") is added to the front of the UniqueName of the column. I noticed it in Chrome DevTools when I inspected the element from the browser. I should note that "FileName" is the UniqueName of the column in case you didn't want to read through the code above.