开发者

ITemplate and linkbutton click event

开发者 https://www.devze.com 2023-01-27 07:35 出处:网络
In my user control I have gridview, and this grid is created programmatically, using Itemplate. In InstantiateIn methods I have this code.

In my user control I have gridview, and this grid is created programmatically, using Itemplate. In InstantiateIn methods I have this code.

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)

I want to wir开发者_如何学Goed up Click event to this LinkButton, and use this event in code behind. This is constructor of GridViewTemplate how implements 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

and i have this call from user control:

bfield.ItemTemplate = New GridViewTemplate(ListItemType.Item, dt.Columns(col).ColumnName, "label")

where is

Dim bfield As TemplateField = New TemplateField()


AddHandler linkbutton.Click, AddressOf X 'X being the method that handles the click event.


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

精彩评论

暂无评论...
验证码 换一张
取 消