Solved

Trying to override functionality of UpdateButton in FormView for EditItemTemplate

Posted on 2006-11-12
6
486 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

831 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