Solved

Need help with Datagrid Sorting

Posted on 2004-09-20
3
165 Views
Last Modified: 2010-04-23
I am looking for some help in fixing a datagrid problem. I am using the following code to capture a double click and open our Order Entry form:

'Add Textbox Double Click Hander
AddHandler dgcsOrderID.TextBox.DoubleClick, New EventHandler(AddressOf TextBoxDoubleClickHandler)

'Opens Order Form with Double Clicked Order ID
Private Sub TextBoxDoubleClickHandler(ByVal sender As Object, ByVal e As EventArgs)
        Dim drID As DataRow = objdsOrders.qryLIST_Orders.Rows(dgOrders.CurrentCell.RowNumber)
        Dim intOrderID As Integer = drID.Item("OrderID")

        If intdblclickcount = 0 Then
            OpenDisplay(intOrderID)
            intdblclickcount = 1
        End If
End Sub


This works fine when the form is first opened. However, when I sort on any column header, the data sorts, but apparently, the underlying data [objdsOrder.qryLIST_Orders.Rows(dgOrders.CurrentCell.RowNumber)] does not. When I double click the order ID, it opens the original unsorted value of that row, not the display data. For example:

Before I sort the data:
Order     Customer
00001     Bob
00002     Steve
00003     Alan

Clicking on row one opens Bob's order - this is fine.

After I sort the data:
Order     Customer
00003     Alan
00001     Bob
00002     Steve

Clicking on row one still opens Bob's order - this is not fine.

I need a way to retrieve the sorted data, and points will be awarded to code that accomplishes that. TIA.

0
Comment
Question by:PEIAFowler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Expert Comment

by:bramsquad
ID: 12105799
its becuase your still pulling the data from your datasource

you need to pull the data from your datagrid

just cut your code down to

Dim drID As DataRow = dgOrders.CurrentCell.RowNumber
Dim intOrderID As Integer = dgOrders.Item(dgOrders.CurrentCell.RowNumber, dgOrders.CurrentCell.ColumnNumber)

just replace dgOrders.CurrentCell.RowNumber with a constant value where that field exists.

~b
0
 
LVL 8

Accepted Solution

by:
bramsquad earned 500 total points
ID: 12105807
you actually dont need the first line of code (the datarow)

just use the second, that will give you your value
0
 

Author Comment

by:PEIAFowler
ID: 12105857
Worked like a charm - thanks!
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
"lblTime is not declared" 3 65
Convert VB web project to C# 3 66
vb.net dbnull syntax 1 56
EMAIL RANGES BASED ON CURRENT TIME 12 39
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question