使用 CommandArguement="value" 隐藏所有链接按钮

Hide all linkbuttons with CommandArguement="value"

有没有办法检查所有具有指定 CommandArgument 值的链接按钮和 hide/show 它们在 vb.net 中?

例如:

<asp:LinkButton ID="LinkButton3" runat="server" class="thumbnail" style="text-align:center;" OnClick="display" CommandArgument="App1"/>
<asp:LinkButton ID="LinkButton4" runat="server" class="thumbnail" style="text-align:center;" OnClick="display" CommandArgument="App2"/>
<asp:LinkButton ID="LinkButton5" runat="server" class="thumbnail" style="text-align:center;" OnClick="display" CommandArgument="App1"/>

在 vb.net 我想做以下事情 [下面只是我想要的文字]

for each [Link buttons where CommandArguement = "App1" ]
    Linkbutton[].Visible = false
next

更新:

我尝试构建类似的东西,但 c.CommandArgument 不起作用。 我已经对链接按钮进行了强制转换并从中获取了 CommandArgument 但那是在单击链接按钮并返回它之后,这与我要完成的场景不同。

尝试:

 Dim controlId As String = ""
    Dim cControl As Control

    For Each c As Control In cControl.Controls
        If TypeOf c Is LinkButton Then
            'Or whatever that is you checking for 
            If c.commandArgument = "App1" Then

            End If

        End If
    Next

点击后有效的代码示例

 Dim btn As LinkButton = DirectCast(sender, LinkButton)
 Dim yourValue As String = btn.CommandArgument

错过了 btn 声明

Dim c2 As Control
    For Each c2 In pnl1.Controls
        If TypeOf c2 Is LinkButton Then

            Dim btn As LinkButton = c2
            Dim val As String = btn.CommandArgument

            If val.Contains("App1") Then

            End If
        End If

    Next