Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sort datarows

Posted on 2004-08-06
7
Medium Priority
?
621 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

670 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