0

我每行都有Repeater一个LinkButton。我希望能够读取LabelLinkButton. 这是我当前正在使用的代码,但我不确定在我的“单击”方法中放置什么链接按钮以获取我行中其他控件的值。

中继器 ItemDataBound

Private Sub Repeater_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater.ItemDataBound

   Dim oRow As xsdTable.MyDataTableRow
   Dim RemoveLinkButton As LinkButton

   RemoveLinkButton = e.Item.FindControl("RemoveLinkButton")
   AddHandler RemoveLinkButton.Click, AddressOf RemoveLinkButton_Click

   // Set other Controls Information   

End Sub

RemoveLinkBut​​ton 点击​​事件

Public Sub RemoveLinkButton_Click(sender As Object, e As System.EventArgs)

    // Not sure what to do here to get the id for that row and identify the other 
    // controls to get the information from them...

End Sub
4

1 回答 1

1

您可以使用 NamingContainer控件的属性来获取RepeaterItem

Public Sub RemoveLinkButton_Click(sender As Object, e As System.EventArgs)

    Dim control = DirectCast(sender, Control)
    Dim item = DirectCast(control.NamingContainer, RepeaterItem)
    ' now use FindControl to get the other controls in this item '

End Sub
于 2012-11-15T16:23:03.597 回答