2010-11-26 69 views
0

在我的用户控件中,我有gridview,并且这个网格是使用Itemplate以编程方式创建的。在InstantiateIn方法中,我有这个代码。ITemplate和linkbutton点击事件

我想将Click事件连接到此LinkBut​​ton,并在后面的代码中使用此事件。 这是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
AddHandler linkbutton.Click, AddressOf X 'X being the method that handles the click event. 
+0

我有公共类如何实现这个ITem盘子。我不能使用这个。我尝试使用代表,但没有任何运气。 – amchoni 2010-11-26 22:07:13

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 
+0

我有公开课,怎么实现这个ITemplate。我不能使用这个。我尝试使用代表,但没有任何运气。 – amchoni 2010-11-26 22:09:48