?
Solved

Trying to override functionality of UpdateButton in FormView for EditItemTemplate

Posted on 2006-11-12
6
Medium Priority
?
512 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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