Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2008, 04:38 AM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default DetailsView Cancel button to redirect

Hi! I want the detailsview cancel button to redirect the page into another page. What is the event to configure so that the response.redirect statement can be inserted?



 
Old June 21st, 2008, 06:22 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

There are a few ways to do this:

1. Handle the ItemCommand of the DetailsView and then check e.CommandName:

protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
{
  switch (e.CommandName)
  { .. }
}

2. Convert the CommandField into a TemplateField and then manually wire up the Cancel button to a Click handler in the code behind.

Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old June 22nd, 2008, 10:57 PM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have used the 2nd option and I implemented:

Dim Linkbutton2 As LinkButton = _ CType(DetailsView1.FindControl("LinkButton2"), LinkButton)

Linkbutton2.<What should I insert here?> = String.Concat("CustomerInsert.aspx?EmployeeID=", Request("EmployeeID"))

What should I insert there?

Thanks

 
Old June 22nd, 2008, 11:02 PM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have implemented another way:

<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
OnClick="Cancel_Sub" CommandName="Cancel" ext="Cancel"></asp:LinkButton>


Protected Sub Cancel_Sub()
        Response.Redirect("CustomerView.aspx?EmployeeID=" & Request("EmployeeID"))
    End Sub

 
Old June 23rd, 2008, 01:23 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, that's the solution I had in mind as well....

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Paramater value cancel button errors REVNED VB How-To 1 September 2nd, 2008 01:23 PM
How to stop file uploading when a cancel button coolcoder2007 ASP.NET 2.0 Basics 0 October 26th, 2007 04:21 AM
Moving the new/insert button on DetailsView jpullam ASP.NET 2.0 Basics 3 September 27th, 2007 05:29 PM
Button on GridView that goes to DetailsView AndrewD ASP.NET 2.0 Basics 0 November 30th, 2005 11:09 AM
Problem with cancel and next button in form method Access VBA 0 June 18th, 2005 02:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.