Solved

sort datarows

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

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 …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

21 Experts available now in Live!

Get 1:1 Help Now