Q:

htmlTableRow not in designer

I'm now responsible for an ASP.net VB web forms application that I need to make a change to. I don't have much experience with asp.net so if I don't have this process right please let me know. I'm trying to hide two table rows depending on user permissions inside a nested table inside a repeater -- but the IDs of the TR don't appear in the designer and if I add it manually they don't stay long before VS removes it. In code behind, I'm getting is not declared errors for both IDs
<table>
    <asp:repeater ID="history" runat="server" OnItemDataBound="historyDetails">
        <itemTemplate>
            <tr>
                <td>
                    <table>
                        <%-- 
                        I'm trying to hide these 2 rows conditionally
                        without using <% if isAdmin then %> <% end if %> 
                        --%>
                        <tr id = "adminHeading" runat="server">
                            <td>...</td>
                        </tr>
                        <tr id = "adminNav" runat="server">
                            <td>...</td>
                        </tr>
                        <tr>...</tr>
                    </table>
                </td>
            </tr>
        </itemTemplate>
    </asp:repeater>
</table>

code behind
Protected Sub historyDetails(ByVal sender As Object)
    ...
    ...
    If session("isAdmin") Then
        adminHeading.visible = True 'produces not declared error
        adminNav.visible = True 'produces not declared error
    End If
End Sub

A:

The reason you are not able to access adminHeading & adminNav in your code behind is because they are not direct present in your form tag directly rather they are present inside the repeater control. You can do this with ItemDataBound event by finding these table rows like this:-
Protected Sub historyDetails(sender As Object, e As RepeaterItemEventArgs)
   If (e.Item.ItemType = ListItemType.AlternatingItem Or _
       e.Item.ItemType = ListItemType.Item) Then
         Dim adminHeading As HtmlTableRow = TryCast(e.Item.FindControl("adminHeading"), _
                                                    HtmlTableRow)
         Dim adminNavAs HtmlTableRow = TryCast(e.Item.FindControl("adminNav"), _
                                                    HtmlTableRow)
     'Check your condition and hide the rows
     If session("isAdmin") Then
         adminHeading.Visible = False
         adminNavAs.Visible = False
     End If
   End If
End Sub

