Datagrid UpdateCommand Not Being Called

watch00

New member
Joined
Mar 22, 2005
Messages
2
Programming Experience
3-5
i add the handling function manually as such
where dg is a datagrid and dg has a editcommandcolumn
(all my datagrids are dynamically created)

AddHandler dg.EditCommand, AddressOf Grid_EditCommand
AddHandler dg.UpdateCommand, AddressOf Grid_UpdateCommand
AddHandler dg.CancelCommand, AddressOf Grid_CancelCommand
AddHandler dg.ItemCommand, AddressOf Grid_ItemCommand

I write a function
Private Sub Grid_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
......
end sub
Private Sub Grid_EditCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
......
end sub

when i step through the code, the Grid_EditCommand gets called, when i press the edit button.
however, when i the press the update button, the Grid_UpdateCommand never gets called. rather, the Grid_editCommand gets called.


WHAT AM I DOING WRONG HERE?????
(neither the Grid_CancelCommand gets called)



 
I had a problem like this before as well. You really only need one handler and take action based on the exact DataGridCommandEventArgs that are passed:

VB.NET:
[size=2][color=#0000ff]Private[/color][/size][size=2][color=#0000ff] Sub[/color][/size][size=2] Grid_ItemCommand([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] DataGridCommandEventArgs)
   Select Case e.CommandName
	  Case "Update"
		 ' Update Code
	  Case "Edit"
		 ' Edit Code
	  Case "Cancel"
		 ' Cancel Code
	  Case else
		 ' any other commands you may have
   End Select
End Sub

[/size]
 
Back
Top