use Formview cancel commandname to return to GridView Page?

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.
 
A

Anthony Merante

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

Try something like this:

DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();
 
G

Guest

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"
 
G

Guest

Thanks Anthony but I'm actually using a formView on a different page than the
GridView.
 
G

Guest

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!
 

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

Similar Threads


Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top