Solved

Redirect after DeleteCommand from FormView

Posted on 2008-10-03
4
595 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
[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
  • 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

729 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