Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
  #11 (permalink)  
Old September 20th, 2007, 03:32 PM
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

Swapping items in a list is not a trivial thing to do. Here's what I would do (pseudo code)

1. Add a SortOrder column to your database and Business Object.

2. Bind the list and display up / down arrows.

3. When one of the items is clicked find the "other item". E.g. the one above when the Up arrow is clicked or the one below with the Down arrow.

4. For both items, get its unique ID. You can use the clicked item's index in the Grid, then add or subtract one from that index to find the other and then use the DataKeys collection to find the unique IDs.

5. Fetch both items using something like GetItem

6. Swap the sort order for both items using a temp variable. E.g.

int tempSortOrder;
tempSortOrder = a.SortOrder;
a.SortOrder = b.SortOrder;
b.SortOrder = tempSortOrder;
a.Save();
b.Save();

That should swap the items and update them in the database.

I have no idea what you mean with your other question. I don't understand "i need to do a gridview.datasource ans gridview.databind in the event handlers..!" and "Right now I m storing it in Session during first load and using it the the paging/sorting event handlers.." so I can't recommend "any better way of doing this"

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004




Similar Threads
Thread Thread Starter Forum Replies Last Post
strongly-typed DataSet.Rows r n't getting Updated srkvellanki ASP.NET 2.0 Professional 3 October 1st, 2008 05:26 PM
"Strongly typed" roman BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 June 26th, 2008 10:35 AM
Record Locking & Transactions in Strongly Typed DS Kia Visual Basic 2005 Basics 4 July 23rd, 2007 06:23 AM
Accessing Strongly Typed Session Data Woodman ASP.NET 2.0 Professional 2 March 9th, 2007 04:42 PM
Crystal Report and Strongly-Typed dataset jaucourt Crystal Reports 1 February 9th, 2004 07:39 AM





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