Monday, March 23, 2009

ASP.NET ListView Cancelling Problem

I recently changed some GridViews over to ListViews in order to better handle the UI elements when inserting and editing items. On hitting the Cancel button, I received the following error:

Cancel can only be called from the currently-edited record or an insert item.

I finally found out that the problem was running the following code in the ItemCommand:

lvScopeNote.InsertItemPosition = InsertItemPosition.None
lvScopeNote.EditIndex = -1

Moving those commands to the ItemCanceling event caused the operation to work correctly.

No comments:

Post a Comment