Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need help with Datagrid Sorting

Posted on 2004-09-20
3
Medium Priority
?
168 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 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