use Formview cancel commandname to return to GridView Page?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to code a FormView page to return to the Gridview List if the user
clicks the Cancel button while in insert mode but nothing happens with the
following code:

void VanDetailFormView_ItemCommand(Object sender,
FormViewCommandEventArgs e)
{
if (e.CommandName == "Cancel")
{
Response.Redirect("VanList.aspx");
}
}

Is there a better way to do this?

Thanks.
 
I think you'll just want to take the Grid out of editmode

Try something like this:

DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();
 
If you want to consume the ItemCommand, make sure you wired the event for it
properly, e.g. add in the markup of the FormView:
OnItemCommand="VanDetailFormView_ItemCommand"
 
Thanks Phillip, that's the ticket! I guess I need to read up on these
builtin GridView events vs the ones I need to add to understand the
interaction between them and my own handlers.

Thanks again!
 
Back
Top