Wrox Programmer Forums
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB 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 January 5th, 2014, 07:00 PM
Authorized User
Join Date: Aug 2011
Posts: 44
Thanks: 14
Thanked 0 Times in 0 Posts
Default Enabling deleting in GridViews

Hello Imar,

in chapter 13, you set up two GridViews (one for the Genres and the other for the Reviews).

Both GridViews have a Delete button in common.

For the Genres, you enabled Deleting in the Smart Tasks panel of the GridView (page 459), whereas for the Reviews you generated the Delete statement in the Smart Tasks panel of the SqlDataSource (page 474).

Can you explain the reason for these different approaches ?
When should I take the first way and when the second one ?

Thank you
Old January 6th, 2014, 10:13 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

Although it may not be obvious at first, both methods actually do the same thing.

When you drag the database table on the page (step 7 on page 458), Visual Studio creates a SqlDataSource that supports deleting. For the manually created data source, you need to do this explicitly. The result is the same: the SqlDataSource has its DeleteCommand set up.

Deleting in the GridView is configured differently as well, but the final result is the same. When you enable it in the Smart Tasks panel, VS adds the following code to the GridView:

<asp:CommandField ShowDeleteButton="True" />
For the second GridView, in step 5 on page 475, you create a CommandField with its ShowDeleteButton set to true, resulting in the exact same code.

Hope this helps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
Antonius Block (January 6th, 2014)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridviews, dropdown lists, and a Sqldatasource rexcampbell BOOK: Beginning ASP.NET 4.5 : in C# and VB 6 March 18th, 2013 10:27 AM
Tab across gridviews cdw90nl Javascript How-To 1 February 4th, 2008 05:16 AM
Nested gridviews johncross912 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 November 23rd, 2007 03:04 AM
Gridviews lisabb ASP.NET 2.0 Basics 1 May 29th, 2007 11:40 AM
four Nested gridviews with data KamalRaturi ASP.NET 2.0 Professional 0 November 15th, 2006 10:17 PM

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