Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #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
Default

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

jimi

http://www.jamestollan.com
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.