Cloud_Strife
New Member
I am facing problem adding events use to dynamically created control.I will able to attach the event.But when I pressing the dynamically loaded button ,the attched event not firing.<BR><BR>On selection of datagridItem load new button control in Cell0.<BR>Public Sub MyDataGrid_Select(ByVal sender As Object, ByVal e As EventArgs)<BR> Dim btn as New Button() //New Button<BR> btn.ID = "btn"<BR> btn.Text = "-"<BR> AddHandler Me.btn.Click, AddressOf btn_divFalse //Adding Event to new button<BR> MyDataGrid.SelectedItem.Cells(0).Controls.Add(btn)//Adding control to datagrid.<BR>End sub<BR><BR>Public Sub btn_divFalse(ByVal s As Object, ByVal e As System.EventArgs)<BR> Dim chkBox As New CheckBox()<BR> chkBox = CType(MyDataGrid.SelectedItem.Cells(4).FindControl ("chkSelect"), CheckBox)<BR> MyDataGrid.SelectedIndex = -1<BR> AllResourceDetails.Visible = False<BR> End Sub