Update Before Redirecting

P

Phillip Vong

Please help a newbie.

Newbie using VS2005 and ASPX.

I have page1.aspx and page2.aspx. Page2 is using FormView and in the
EditItem Template, I want people to be redirected to page1.aspx after they
have updated the data to the DB.

In the UpdateButton_Click, I used the simple Response.Redirect
("page1.aspx"). The problem is that the UpdateButton_Click takes priority so
it just redirects me to page1.aspx withouth updating the DB. How do I get it
to update the DB first and then redirect me to page1.aspx?

I created a simple test example and I have the code here:
http://pastebin.com/755938

Thanks in advance.

Phil
 
G

Guest

Hello Phillip,

Add an event handler to the FormView control to handle the ItemUpdated
event. This event fires after the update command has been executed on the
data source. In the event handler redirect to the page1.aspx:

protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs
e)
{
Response.Redirect("Page1.aspx");
}
 
P

Phillip Vong

Brians - Thanks so much. That was perfect and it really helps me in
learning. Can you do me the favor and answer my other question right above
this one?

Thanks again!

Phil
 
N

Ned Balzer

I found that this didn't work unless I also added a clause like
"handles FormView1.itemUpdated" in the Sub declaration

ie.
I'm not sure why this was required since many of the code samples I've
looked at don't have it.

-- Ned
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top