Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 April 16th, 2004, 03:10 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

The datagrid has a collection called DataKeys. You set a data table field to the datagrid's DataKeyField and the grid will populate this collection with the values from that field. This is how you can get at the key field for a given datagrid row.

So, in your for each you need only access that data key value. Also, you probably should avoid refreshing the grid on each iteration becase A) it's redundant and wastes cycles and B) it could cause things to break, particularly when you are doing a Enumerator loop of the grid's items collection.

    For Each oDataGridItem In dgReCart.Items
        chkRemove = oDataGridItem.FindControl("chkDelete")
        If chkRemove.Checked Then
            bl.DeleteItemFrCart(dgReCart.DataKeys(oDataGridIte m.ItemIndex))
        End If

Work smarter, not harder

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shopping cart help rsm42 ASP.NET 1.0 and 1.1 Basics 3 December 9th, 2006 06:09 AM
Problem Creating Shopping Cart Object jazzcatone ASP.NET 2.0 Basics 2 April 24th, 2006 08:46 PM
shopping cart xipnl BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 June 10th, 2005 07:00 PM
Shopping cart Manoj babu General .NET 0 February 14th, 2005 04:20 AM
shopping cart isheikh BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 October 8th, 2004 04:20 PM

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