Solved

sort datarows

Posted on 2004-08-06
7
620 Views
Last Modified: 2006-11-17
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
Comment
Question by:dean47
[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
  • 2
7 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11740803
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
 
LVL 3

Accepted Solution

by:
realrael earned 250 total points
ID: 11742113

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
 
LVL 3

Expert Comment

by:realrael
ID: 11931290

i'm interested. - rael
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 12064899
I think both methods would solve it though from the question there are still some questions as to what is required.
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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

627 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