Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

sort datarows

I am trying to sort rows in a dataset and sind a particular name and then cause it to display a picture.  But it shows all the pictures everytime.  This is the code I am using:

Private Sub dgClothing_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgClothing.CurrentCellChanged
        Dim pintTransactions As Integer
        Dim pintCount As Integer

        Dim drArray() As DataRow = dsClothing.tblClothing.Select(Nothing, Nothing, DataViewRowState.CurrentRows)

        For pintCount = 0 To drArray.GetUpperBound(0)

            If drArray(pintCount).Item("fldClothing_Description").ToString = "Jeans" Then
                Call OpenJeans()
            ElseIf drArray(pintCount).Item("fldClothing_Description").ToString = "Flower Dress" Then
                Call OpenDress()
            ElseIf drArray(pintCount).Item("fldClothing_Description").ToString = "Silk Blouse" Then

                Call OpenBlouse()
            ElseIf drArray(pintCount).Item("fldClothing_Description").ToString = "Pink T-Shirt" Then
                Call OpenShirt()
            Else
                MsgBox("No Picture available for that item at this time")
            End If
        Next
    End Sub

Can someone tell me what I have done wrong?
0
dean47
Asked:
dean47
  • 2
  • 2
1 Solution
 
gregoryyoungCommented:
you are trying to sort them or filter them ?

try ...

DataView dv = new DataView(dsClothing.tblClothing)
dv.RowFilter = "columnname = 'whatever'"

if you want to sort after that you can use

dv.Sort = "columnname"

0
 
realraelCommented:

i think this is what you intend to do: get the selected record's clothing type and call the appropriate function based from that. see code below.

if you've found the right type, you don't have to go through the rest of the array so issue an "exit for" command.

let me know if this helps.

- rael

---
...
        'save the current record's clothing type to this variable
        clothing_type = ...

        For pintCount = 0 To drArray.GetUpperBound(0)

            If drArray(pintCount).Item("fldClothing_Description").ToString = clothing_type Then
                Call OpenJeans()
                exit for
            ElseIf drArray(pintCount).Item("fldClothing_Description").ToString = clothing_type Then
                Call OpenDress()
                exit for
            ElseIf drArray(pintCount).Item("fldClothing_Description").ToString = clothing_type Then
                Call OpenBlouse()
                exit for
            ElseIf drArray(pintCount).Item("fldClothing_Description").ToString = clothing_type Then
                Call OpenShirt()
                exit for
            Else
                MsgBox("No Picture available for that item at this time")
            End If
        Next
...
0
 
realraelCommented:

i'm interested. - rael
0
 
gregoryyoungCommented:
I think both methods would solve it though from the question there are still some questions as to what is required.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now