Solved

Need help with Datagrid Sorting

Posted on 2004-09-20
3
161 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Make a border less form movable 2 23
Programmatically signing Word macros 4 61
Vb.net dynamic formulas in runtime 11 63
Change Format on Data when exporting to Excel 4 23
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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now