【问题标题】:How do I access properties of non-fired LinkButtons in an ASP RepeaterControl?如何访问 ASP RepeaterControl 中未触发的 LinkBut​​tons 的属性?
【发布时间】:2011-08-18 11:58:20
【问题描述】:

我有一个导航栏,它通过 ASP repeaterControl 使用 LinkBut​​tons 动态填充。

我在访问和设置单击的 LinkBut​​ton 的属性时没有问题。我可以使用触发的 LinkBut​​ton 中的发送者对象来做到这一点。单击链接按钮后,它会以粗体突出显示。

我的问题是在单击新的 LinkBut​​ton(同一中继器中的另一个 RepeaterItem)时清除先前单击的 linkBut​​ton 的粗体属性。

对此有什么想法吗?非常感谢!

ps。 我无法通过它们的 ID 访问这些按钮,因为它们在中继器中都有相同的 ID。

我在每个 RepeaterItem (CommandArgument) 上都有唯一的参数,但是当我尝试遍历所有链接按钮时,只找到静态链接按钮,中继器内没有。见下文:

Dim c As Control
For Each c In Form1.Controls
    If TypeOf c Is LinkButton Then
        MsgBox(DirectCast(c, LinkButton).CommandArgument)
    End If
Next c

【问题讨论】:

    标签: asp.net vb.net linkbutton asprepeater


    【解决方案1】:

    试试这个:

    For each item as RepeaterItem in YourRepeaterControl.Items
    
        Dim button as LinkButton = item.FindControl("YourLinkButtonId")
        If button IsNot Nothing Then
            'Do whatever you want here
        End If
    
    Next
    

    【讨论】:

      猜你喜欢
      • 2012-09-09
      • 2011-06-16
      • 2014-04-14
      • 2019-07-15
      • 2019-07-11
      • 1970-01-01
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多