Solved

sort datarows

Posted on 2004-08-06
7
618 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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