Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EditCommandColumn and ItemCommand in one DataGread

Status
Not open for further replies.

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.


 
Without seeing all of the code behind related to this issue, I can only guess. Maybe there is something int the Itemcommand event that is interfering with the editcommand event.
 

Thanks much! Encouraged by your answer (which meant to me that both features should work in one datagreed and that i should look up an error in ItemCommand sub). My error was there.
thank you jbenson001 :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top