CancelCommand Not Firing!

S

Scott M.

I have an asp:DataGrid control with EnableViewState=False. I am calling
DataBind on both the non-postback and the postback. I am persisting the
state of the grid myself and restoring the state (selectedItem, editItem,
sortCommand, etc.). Everything is working just fine EXCEPT the
CancelCommand event is not firing. All the other events ARE firing.

Any ideas?
 
E

Elton Wang

Show your code please.

Elton Wang
(e-mail address removed)
-----Original Message-----
I have an asp:DataGrid control with
EnableViewState=False. I am calling
 
S

Scott M.

Private Sub dg_CancelCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.CancelCommand

dg.EditItemIndex = -1
dg.DataBind()

End Sub

SortCommand event fires, PageIndexChanged event fires, SelectedIndexChanged
event fires, EditCommand fires, CancelCommand does not but it does have the
correct Handles clause.
 
E

Elton Wang

Unfortunately once you disable ViewState of the datagrid,
it seems the system can't correctly transfer link button
name, no matter you click Edit, or Cancel, or Update
button, it only gives Edit. Hence it only fires Edit
(selectedItem, SortCommand are not affected).

HTH,

Elton Wang
(e-mail address removed)

-----Original Message-----
I have an asp:DataGrid control with
EnableViewState=False. I am calling
 
S

Scott M.

I'm afraid that analysis is incorrect. I'm not using LinkButton controls
anyway and (as I mentioned) all other events are firing properly except the
CancelCommand event.
 
E

Elton Wang

Although you aren't explicitly using linkButton, you are
actually using it when you are using EditCommandColumn.
Why don't you create ItemCommand event and debug into the
event to see what happens?

Elton Wang
 
S

Scott M.

I really don't think the linkButton is being used as I have configured the
grid to use a Web Forms Button instead of a linkButton.

I could debug the ItemCreated event, but that would tell me what I already
know...that the CancelCommand is not firing.

I'm not trying to diagnose...I have the diagnosis, what I'm looking for is
the cure.

Thank you anyway.
 
Q

quang.lai

Elton Wang said:
Unfortunately once you disable ViewState of the datagrid,
it seems the system can't correctly transfer link button
name, no matter you click Edit, or Cancel, or Update
button, it only gives Edit. Hence it only fires Edit
(selectedItem, SortCommand are not affected).

I'm having a similar problem and just noticed what you mentioned. Is
there a known work around for this?

When I enable ViewState for my dataGrid, I get the "Failed to load
viewState" when any action is done on the first row of my datagrid.
JUST the first row. I can modify and manipulate any other row and I
won't get the "Failed to load viewState" error. I'm not dynamically
adding/deleting any controls either.

What are my options?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top