Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking 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 Basics 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 September 21st, 2011, 03:19 PM
Registered User
Join Date: Sep 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to move rows in a datagrid with VB

I'm enhancing an older app and have be working with ItemCommands to move rows in the datagrid up or down. Can anyone guide me to the best way to do this with examples? Any help is greatly appreciated.
Old October 19th, 2011, 05:45 AM
Registered User
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

I have made this sub procedure. Try by using it on Button click event in your code. Hope this will work as per your requirement.

Public Sub MoveUp(ByRef firstRow As System.Windows.Forms.DataGridViewRow, ByRef nextRow As System.Windows.Forms.DataGridViewRow)
'Create a temporary value
Dim temp As Object
Dim temp2 As Object

'Loop through each cell in the firstRow datagridview
Dim i As Integer
For i = 0 To firstRow.Cells.Count - 1
'If the cell isn't read only, then swap them.
If firstRow.Cells(i).ReadOnly = False Then
'use the temp object to swap the cell values.
temp = firstRow.Cells(i).Value
temp2 = nextRow.Cells(i).Value

firstRow.Cells(i).Value = temp2
nextRow.Cells(i).Value = temp
End If
End Sub
Old October 20th, 2012, 04:00 AM
Registered User
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

I have done this code but it is in c#,so will it help you?

manuka honey

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to move rows in a table bucky483 Javascript How-To 10 March 27th, 2017 12:57 AM
vb 2010 datatable move next, move previouse bigway .NET 4 and Visual Studio 2010 General Discussions 1 July 13th, 2011 03:55 AM
move next rows in DataGrid < > prop. not correct fbailey ASP.NET 1.0 and 1.1 Basics 3 September 5th, 2007 10:17 AM
Move Datagrid rows michael29 ASP.NET 1.0 and 1.1 Professional 1 April 24th, 2007 05:31 PM
move rows to top with cells in columnA filled RED alienscript Excel VBA 2 December 2nd, 2003 12:51 PM

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