I have a hierarchical(or however its spelled) grid, a master(account), first detail(contact) second detail(phone numbers). On the detail grids i have added command items to allow the user to add new contacts to a account or phone numbers to a contact. I also have an edit button in the grid so they can change current values.
I'm using the EditForm Template in a PopUp edit mode, when i click the Add new button in the Command Item i get the InitInsert name in ItemCommand and in item databound the grid is in edit mode, since it uses the same form for edit and insert i show and hide different fields on data bound, if its editing or inserting, i also change the command name of the button on the form so i know what to do when the user clicks it (insertContact, UpdateContact, etc..) On Insert everything works, the proper fields are displayed the proper command name gets passed back to the ItemCommand event, however on Edit the display works (only the editable fields are shown) and in ItemDataBound the grid is in edit mode, the popup shows. When i click the edit button the popup shows and when i click the update button ItemCommand still fires and i get the UpdateContact command name, but the grid is no longer in edit mode. I cant find a way to access the controls that were in the edit form popup since the event args in ItemCommand is a GridDataItem and not a GridEditFormItem like it is on an Insert.
Basically i need to know if i can share the same form for Edits and Inserts(since i dont seem to have a choice), and how can i get to the controls on the edit form from the ItemCommand event if e.Item isnt a GridEditFormItem. I've checked a lot of the help documentation, but cant seem to find a way to accomplish what i need to do.
EDIT:
The problem appears to be caused by me changing the CommandName of the button for an Edit. If you leave(or set) the CommandName as "Update" everything works correctly in the ItemCommand Event. I just put a flag in the CommandArgument property to figure out which update code i should run.
Wish there was a better way like EditForm and InsertForm templates to keep everything seperate, and not have to have code in ItemCommand and ItemDataBound to hide and show bits but oh well.
/EDIT
I'm using the EditForm Template in a PopUp edit mode, when i click the Add new button in the Command Item i get the InitInsert name in ItemCommand and in item databound the grid is in edit mode, since it uses the same form for edit and insert i show and hide different fields on data bound, if its editing or inserting, i also change the command name of the button on the form so i know what to do when the user clicks it (insertContact, UpdateContact, etc..) On Insert everything works, the proper fields are displayed the proper command name gets passed back to the ItemCommand event, however on Edit the display works (only the editable fields are shown) and in ItemDataBound the grid is in edit mode, the popup shows. When i click the edit button the popup shows and when i click the update button ItemCommand still fires and i get the UpdateContact command name, but the grid is no longer in edit mode. I cant find a way to access the controls that were in the edit form popup since the event args in ItemCommand is a GridDataItem and not a GridEditFormItem like it is on an Insert.
Basically i need to know if i can share the same form for Edits and Inserts(since i dont seem to have a choice), and how can i get to the controls on the edit form from the ItemCommand event if e.Item isnt a GridEditFormItem. I've checked a lot of the help documentation, but cant seem to find a way to accomplish what i need to do.
EDIT:
The problem appears to be caused by me changing the CommandName of the button for an Edit. If you leave(or set) the CommandName as "Update" everything works correctly in the ItemCommand Event. I just put a flag in the CommandArgument property to figure out which update code i should run.
Wish there was a better way like EditForm and InsertForm templates to keep everything seperate, and not have to have code in ItemCommand and ItemDataBound to hide and show bits but oh well.
/EDIT