Solved

Trying to override functionality of UpdateButton in FormView for EditItemTemplate

Posted on 2006-11-12
6
466 Views
Last Modified: 2008-01-09
Hi,

I want a page with a FormView to save the record but to go to some other page (not the current page).

At first I tried setting the PostBackUrl to the new page.  It went to the new page but was not saving the form data.

So then I tried capturing the UpdateButton_Click event.  This is what it looks like:

    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        FormView1.UpdateItem(true);
        LinkButton lb = (LinkButton)FormView1.FindControl("UpdateButton");
        lb.PostBackUrl = "Deal.aspx?BookId=" + Request["BookId"];
       
    }

I put a Breakpoint in this routine and it does hit this but it must be too early (or too late) for the PostbackUrl to be changed.

I don't have to do it like above if someone has a better way of doing it.

Thanks
0
Comment
Question by:techhound
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17929256
Would a Server.Transfer("Deal.aspx?BookId=" + Request["BookId"]); work?

Bob
0
 

Author Comment

by:techhound
ID: 17930002
Place this in the UpdateButton_Click event?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17930013
Yes.

Bob
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:techhound
ID: 17930870
Hey Bob,

Thanks for the suggestion but it didn't seem to work. Here is the code that I used:

    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        FormView1.UpdateItem(true);
        Server.Transfer("Default.aspx");
    }

I also tried the FormView1.UpdateItem(false) but it stays on the same form.

Thanks
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17930901
Does the UpdateButton_Click event fire?  I wonder if Server.Transfer is unreachable code.

Bob
0
 

Author Comment

by:techhound
ID: 17931269
I was looking at the wrong event.  Your solution works great!

Thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now