在我的用户控件中,我有gridview,这个网格是使用Itemplate以编程方式创建的。在InstantiateIn方法中,我有这段代码。
Select Case _templateType
Case ListItemType.Header
Dim linkButton As New LinkButton
linkButton.Text = "Delete"
linkButton.CommandName = "Click"
linkButton.CommandArgument = Me._columnID
container.Controls.Add(linkButton)
我想将Click事件连接到此LinkButton,并在代码后面使用此事件。 这是GridViewTemplate的构造函数如何实现ITemplate
Public Sub New(ByVal type As ListItemType, ByVal colname As String, Optional ByVal infoType As String = "")
'Stores the template type.
_templateType = type
'Stores the column name.
_columnName = colname
_infoType = infoType
_columnID = columID
End Sub
我从用户控件那里得到了这个电话:
bfield.ItemTemplate = New GridViewTemplate(ListItemType.Item, dt.Columns(col).ColumnName, "label")
在哪里
Dim bfield As TemplateField = New TemplateField()
答案 0 :(得分:0)
AddHandler linkbutton.Click, AddressOf X 'X being the method that handles the click event.
答案 1 :(得分:0)
AddHandler linkButton.Click, AddressOf linkButton_Click
Sub linkButton_Click(ByVal sender As System.Object, ByVal e As EventArgs)
' here is your click handler
End Sub