I'm trying to find a linkbutton inside on my aspx page.
I don't want to find the originator, like the specific sender, I just want to find the overall linkbutton in the itemtemplate and make them all invisible.
Here is the ASPX code where the linkbutton is
<ItemTemplate>
<table>
<tr>
<td>
<asp:TextBox ID="DisplayOP" runat="server" Text="test" Visible="false"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:Linkbutton ID="ItemEmneLabel" runat="server" Text='<%# Eval("Emne") %>' OnClick="ItemShowComments" CommandArgument='<%# Eval("OpslagsID") %>' Visible="true" /></td>
<--- Code Omitted --->
In my code behind .cs file I try to find it like this:
var lnkb = (LinkButton)ListView1.FindControl("ItemEmneLabel");
lnkb.Visible = false;
and this:
var lnkb = (LinkButton)this.ListView1.FindControl("ItemEmneLabel");
lnkb.Visible = false;
However whatever I try I get an error saying:
{"Object reference not set to an instance of an object."}
What am I doing wrong here?