Hi!
I'm adding an asp button to a datagrid on the ItemDataBound event, when
the user clicks on this button, I basically remove the button and create
other 2 buttons... my problem is.. the 2 last buttons doesn't fire his
events... what I'm doing wrong?
Thanks!
Private Sub dtgTest_ItemDat aBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
dtgTest.ItemDat aBound
Dim itemType As ListItemType = e.Item.ItemType
Dim btnEdit As New Button
If ((itemType = ListItemType.Pa ger) Or (itemType =
ListItemType.He ader) Or (itemType = ListItemType.Fo oter)) Then
Return
Else
btnEdit.Style.I tem("BACKGROUND-IMAGE") =
"url(http://localhost/Images/Edit.gif)"
btnEdit.Style.I tem("BACKGROUND-REPEAT") = "no-repeat"
btnEdit.Width = Unit.Pixel(23)
btnEdit.ID = "btnEdit" & e.Item.DataSetI ndex
AddHandler btnEditar.Click , AddressOf Edit
e.Item.Cells(4) .Controls.Add(b tnEdit)
End If
End Sub
Private Sub Edit(ByVal sender As System.Object, ByVal e As
System.EventArg s)
Dim strIDButton As String
Dim index As Integer
Dim btnCancel As New Button
Dim btnSave As New Button
strIDButton = CType(sender, Button).ID
index = Val(Mid(strIDBu tton, Len("btnEdit") + 1,
Len(strIDButton )))
dtgTest.EditIte mIndex = index
dtgTest.DataSou rce = Session("_DataV iew")
dtgTest.DataBin d()
'I try to remove its event handlers before removing the button,
but id doesn't work either
RemoveHandler CType(dtgTest.I tems(index).Cel ls(4).Controls( 0),
Button).Click, AddressOf Edit
dtgTest.Items(i ndex).Cells(4). Controls.Remove At(0)
btnSave.Style.I tem("BACKGROUND-IMAGE") =
"url(http://localhost/Images/Save.gif)"
btnSave.Style.I tem("BACKGROUND-REPEAT") = "no-repeat"
btnSave.Width = Unit.Pixel(23)
btnSave.ID = "btnSave" & index
AddHandler btnSave.Click, AddressOf Save
dtgTest.Items(i ndex).Cells(4). Controls.Add(bt nSave)
btnCancel.Style .Item("BACKGROU ND-IMAGE") =
"url(http://localhost/Images/Cancel.gif)"
btnCancel.Style .Item("BACKGROU ND-REPEAT") = "no-repeat"
btnCancel.Width = Unit.Pixel(23)
btnCancel.ID = "btnCancel" & index
AddHandler btnCancel.Click , AddressOf Cancel
dtgTest.Items(i ndex).Cells(4). Controls.Add(bt nCancel)
End Sub
' This events are not called... why????
Private Sub Cancell(ByVal sender As System.Object, ByVal e As
System.EventArg s)
End Sub
Private Sub Guardar(ByVal sender As System.Object, ByVal e As
System.EventArg s)
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!