Katya85S
Programmer
- Jul 19, 2004
- 190
I need a few buttons in my DataGreed. One should work to edit record content (EditCommandColumn would be perfect for this functionality with its onEdit, OnUpdate and OnCancel commands features), and other buttons should perform functions different from editing, for which ItemCommand would do the thing. When I have just EditCommandColumn with its Subroutines:
Private Sub dg_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.EditCommand
dgAccessRights.EditItemIndex = e.Item.ItemIndex
BindAppRole()
End Sub
Private Sub dg_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.UpdateCommand
‘ some code
End Sub
Private Sub dg_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.CancelCommand
dgAccessRights.EditItemIndex = -1
BindAppRole()
End Sub
each Sub works perfectly and the selected record turns into an Edit mode.
But when I included ItemCommand subroutine:
Private Sub dg_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.ItemCommand
Then, when I hit that Edit button from the EditCommandColumn, the application started throwing an error:
ExecuteNonQuery: CommandText property has not been initialized
so it looks like EditCommandColumn is not recognized by application once ItemCommand Subroutine is included in the application. Is there a work around to have both EditCommandColumn functionality along with ItemCommand event?
Thank you all in advance.
Private Sub dg_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.EditCommand
dgAccessRights.EditItemIndex = e.Item.ItemIndex
BindAppRole()
End Sub
Private Sub dg_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.UpdateCommand
‘ some code
End Sub
Private Sub dg_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.CancelCommand
dgAccessRights.EditItemIndex = -1
BindAppRole()
End Sub
each Sub works perfectly and the selected record turns into an Edit mode.
But when I included ItemCommand subroutine:
Private Sub dg_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.ItemCommand
Then, when I hit that Edit button from the EditCommandColumn, the application started throwing an error:
ExecuteNonQuery: CommandText property has not been initialized
so it looks like EditCommandColumn is not recognized by application once ItemCommand Subroutine is included in the application. Is there a work around to have both EditCommandColumn functionality along with ItemCommand event?
Thank you all in advance.