Solved

Redirect after DeleteCommand from FormView

Posted on 2008-10-03
4
576 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
Comment Utility
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
Comment Utility
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
Comment Utility
In this case, just add a event handler for ItemDeleted event.
0
 

Author Closing Comment

by:ryanvb83
Comment Utility
That worked.  Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now