It is not accessible because it is in the ItemTemplate
of the Formiew
. Only controls which are sitting on top of the page, or better, which NamigContainer
is the Page
can be accessed directly via Id
.
You need to use FindControl
on it's NamingContainer
which is the FormView
that needs to be in the ReadOnly
-mode because it is in the ItemTemplate
.
A good place for the code is the DataBound
- event:
Private Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
Select Case FormView1.CurrentMode
Case FormViewMode.ReadOnly
Dim itemButtons = DirectCast(FormView1.FindControl("itemButtons"), HtmlGenericControl)
itemButtons.isible = True
End Select
End Sub
But why don't you use a Panel
which is rendered as a div if you need to access it on serverside?