Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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
  #1 (permalink)  
Old May 10th, 2007, 04:22 PM
Authorized User
Join Date: Mar 2007
Location: , , .
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
Default GridView Delete Event fires twice

I'm building a site from scratch based on TBH and have been pulling my hair out for nearly 2 days on this one! I added several records to a GridView and then deleted the last record using the delete button (trashcan) and 2 records were deleted. I thought maybe I double-clicked, so I hit delete again and 2 more rows were deleted!

Turns out the problem is cause by a bug in the GridView control that occurs when the delete command is configured to use an image button causing the delete event to fire twice.

I also tested directly on TBH site and the delete event fires twice. Normally you would not be aware of this unless you put a break in the delete method, or happen to notice that several rows were deleted simultaneously.

Even thought the delete always fires twice, sometimes only one row is actually deleted as expected. It appears that multiple rows are only deleted after adding several new rows, and then deleting one of the newly added rows. This is probably why this bug is not encountered more often.

I found several workarounds, one suggests using a Template Field instead of a Command Field if an image button must be used, but I did not actually test. I just changed delete command to a standard button and it works as expected.

Always a fun to encounter this stuff when trying to learn something new!

- Scott.

  #2 (permalink)  
Old May 11th, 2007, 05:36 AM
Friend of Wrox
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts

thanks for that - these kinda things are a real pita. always good when there's a simple solution tho



Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Delete DARSIN ASP.NET 2.0 Basics 2 March 20th, 2007 06:53 AM
Delete Confirmation From within a Gridview rit01 ASP.NET 2.0 Professional 5 March 8th, 2007 06:47 PM
GridView Delete Command jamara ASP.NET 2.0 Professional 0 February 23rd, 2007 02:16 PM
delete using checkboxes in gridview aspvbnet ASP.NET 2.0 Basics 1 November 22nd, 2006 08:28 PM
MouseOut event fires constantly MrSander BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 May 3rd, 2006 11:09 AM

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