Solved

Redirect after DeleteCommand from FormView

Posted on 2008-10-03
4
583 Views
Last Modified: 2013-11-26
Hello.

I have a page with a FormView control.  I have a linkbutton at the bottom that executes the DeleteCommand for the current record being viewed.  The SQL works when I test it in the expression builder.  What I would like to see happen is for the record to be deleted and for the user to be redirected to another page (which shows all records).  Whenever I put the URL in the PostBackUrl property, the user is redirected but the record is not deleted.  It seems like the redilrection is happening before the delete command.  Any ideas?
0
Comment
Question by:ryanvb83
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:joechina
ID: 22634562
At the end of your event which delete the record, add

Response.Redirect("your page shows all records")

PostBackUrl is used to post the form to another page. In your case, you still want to postback to current page, delete the record then redirect.
0
 

Author Comment

by:ryanvb83
ID: 22634613
joechina,

I did not use an event to delete the record.  The LinkButton uses the Delete command which uses the DELETE query in my SQLDataSource.  Should I create an event to handle this?  If so, what type of event?  I already tried that solution in the Click, Command, and DataBinding event but it did not work.
0
 
LVL 13

Accepted Solution

by:
joechina earned 500 total points
ID: 22634839
In this case, just add a event handler for ItemDeleted event.
0
 

Author Closing Comment

by:ryanvb83
ID: 31502773
That worked.  Thanks!
0

Featured Post

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.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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