Solved

Need help with Datagrid Sorting

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

18 Experts available now in Live!

Get 1:1 Help Now