动态linkbutton无法触发事件
在master中有个Table,因为菜单是动态的,所以要动态生成linkButton,但是这个生成后linkButton的Command事件应该如何邦定呢。下边代码是触发的
TdSubMenu2_2.Attributes.Add("onmouseover", strOnmouseover)
TdSubMenu2_2.Attributes.Add("onmouseout", strOnmouseout)
Dim linkButton As LinkButton = Nothing
If SubMuen Is Nothing Then
linkButton = New LinkButton()
subMenuCount = subMenuCount + 1
linkButton.ID = "Lbtn" & i & j
'子菜单的内容
linkButton.Text = dataRowSubmenu(j).Item("SubMenuName").ToString()
'子菜单的连接地址
linkButton.PostBackUrl = dataRowSubmenu(j).Item("SubMenuUrl").ToString()
linkButton.CommandName = "Lbtn"
linkButton.CommandArgument = i & j
AddHandler linkButton.Command, AddressOf Select_Command
hastable.Add(linkButton.ID, linkButton)
Else
linkButton = CType(SubMuen.Item("Lbtn" & i & j), LinkButton)
End If
TdSubMenu2_2.Controls.Add(linkButton)
TrSubMenu2.Cells.Add(TdSubMenu2_2) --------------------编程问答-------------------- 又来一个同样问题。。请在Page_Init或者之前的页面事件之前动态添加控件。
补充:.NET技术 , VB.NET