473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

GridView reorder problems

(Note: Windows XP Pro SP2 + Visual Studio .NET 2005 + SQL Server 2000)

I have a GridView that is populated with data. That last 2 columns are
button fields (image buttons) that have a CommandName of "MoveUp" &
"MoveDown" respectively. In the RowCreated event (for data rows only), I
assign the CommandArgument the index of the current row so that I can
retrieve the Key for the row from the DataKeys collection (in the
RowCommand) event when one of the buttons are clicked.

This key is then passed on to the Business-tier where it calls the
proper Stored Procedure to move the record up/down. The Stored Procedure
has been fully tested through Query Analyzer and works properly all the
time, especially when providing it the data the application is passing
in (as captured during debugging)

However, when debugging (or running live) the code-path jumps around for
unknown reasons. I'll be stepping through a series of sequential lines
of code when the debugger will jump back a few lines and and either
continue on from that point (re-executing statements that have already
been executed) or jump forward again (either to the original line it
jumped back from or forward), etc.

This results in the record not moving at all or moving by 2 rows. I have
rebuilt the website, rebooted my computer, etc. Sometime it works
properly, but only on the first try. Subsequent tries always act strange.

It appears like there are multiple threads running at the same time, but
I am the only user and nobody outside of my machine is allowed access to
the website.

I have been trying to get to the bottom of this for some time now
without success. Does anyone have any ideas how to proceed debugging this?

***** Code *****

ASPX Code:

protected void QResponseGridView_RowCreated( object sender,
GridViewRowEventArgs e )
{
// only work on the 'data' rows
if ( e.Row.RowType == DataControlRowType.DataRow )
{
// Up button
ImageButton upButton =
(ImageButton)e.Row.Cells[ 7 ].Controls[ 0 ];
upButton.CommandArgument = e.Row.RowIndex.ToString();

// hide if it's the first row
if ( e.Row.RowIndex == 0 )
upButton.Visible = false;
// Down button
ImageButton downButton =
(ImageButton)e.Row.Cells[ 8 ].Controls[ 0 ];
downButton.CommandArgument = e.Row.RowIndex.ToString();
}// if
}// QResponseGridView_RowCreated( sender, e )
protected void QResponseGridView_RowCommand( object sender,
GridViewCommandEventArgs e )
{
// 'move' requests
if( e.CommandName == "MoveUp" || e.CommandName == "MoveDown" )
{
// create an instance of the QuestionResponses class
QuestionResponses QResponsesBLL =
new QuestionResponses();

// get the current user performing the action
string username = Membership.GetUser().UserName;

// convert row index from CommandArgument to Integer
int index = Convert.ToInt32( e.CommandArgument );

// retrieve row containing the clicked button
GridViewRow row = QResponseGridView.Rows[ index ];

// get ID from hidden QuestionResponseID field
int questionResponseID =
Convert.ToInt32(
QResponseGridView.DataKeys[
row.DataItemIndex ].Value );

// move response up/down
if ( e.CommandName == "MoveUp" )
QResponsesBLL.MoveResponseUp(
questionResponseID, username );
else
QResponsesBLL.MoveResponseDown(
questionResponseID, username );

// reset the view to show the updates
ResetView(); // rebinds the data to the GridView
}// if
}// QResponseGridView_RowCommand( sender, e )
QuestionResponses Business class:

public bool MoveResponseUp( int questionResponseID, string username )
{
try
{
Adapter.spMoveQuestionResponseUp(
questionResponseID,
GetUser( username ).UserId );

return true;
}
catch( SqlException sqle )
{
return false;
}// try/catch
}// MoveResponseUp( questionResponseID, username )

****************

-={ Kyle K. }=-
Oct 4 '06 #1
0 2098

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mat | last post by:
Reordering Column changes column Indexes???? i use column.index to access(or add ) data in listview. i want to allow user to reorder columns as they need. So i am afraid to get wrong data when user...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
2
by: Asaf | last post by:
Hi, Below is a calss with function I gathered from a news group that uses GetCharacterPlacement API to reorder text. I have mixed text Hebrew/English and the function reorders the Hebrew text. ...
2
by: tacmec | last post by:
ASP.NET 2.0 (C#) application. I have a web form with a GridView, which is populated dynamically. See the code below. First time to the page, IsPostBack is false. Therefore, DisplayItems() is...
1
by: Giovanni | last post by:
Dear Friends/Gurus, I have exhausted myself and have yet no solution to the following: I have an ASP.NET 2.0 Survey type application. On a page, I have placed a GridView which is bound to an...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
1
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I have a GridView that I dynamically add columns to in code. The way that my code is written, everything works properly if I use GridView.Columns.Add to simply add the columns to the end of the...
4
by: rdraider | last post by:
Use the Northwind database Products table as an example. Purchasing dept gets a report showing when inventory items on hand qty are below the reorder level. easy enough: Select ProductID,...
3
by: done4who | last post by:
Heres my problem: my javacript code reads each child element e.g.: <video> <author>skateboard2</author><id>xqWBGvbvw7g</id><title>zach skating</title><length_seconds>100</length_seconds></video>...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.