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
Solved

Find value in Datatable loop

Posted on 2009-05-20
4
646 Views
Last Modified: 2012-05-07
Im trying to find certain text within column 2 of my datatable. Below is what I have so far but its not finding the values even though they exist. Can anyone help me?
For Each DataRow In AS400DS.Rows
            If AS400DS.Columns(2).ToString = "AB" Then
                Absentee.DataField = "Hours"
            ElseIf AS400DS.Columns(2).ToString = "VA" Then
                Vacation.DataField = "Hours"
            ElseIf AS400DS.Columns(2).ToString = "OT" Then
                OT.DataField = "Hours"
            ElseIf AS400DS.Columns(2).ToString = "WH" Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(AS400DS.Columns(2))
        Next

Open in new window

0
Comment
Question by:ITHelper80
  • 2
4 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24433499

For Each oRow As DataRow In AS400DS.Rows
            If oRow (2).ToString = "AB" Then
                Absentee.DataField = "Hours"
            ElseIf oRow (2).ToString = "VA" Then
                Vacation.DataField = "Hours"
            ElseIf oRow (2).ToString = "OT" Then
                OT.DataField = "Hours"
            ElseIf oRow (2).ToString = "WH" Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(oRow(2).ToString)
        Next
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24433519
hi,

try this:
For Each DataRow In AS400DS.Rows
            If LCase(AS400DS.Columns(2).ToString) = LCase("AB") Then
                Absentee.DataField = "Hours"
            ElseIf LCase(AS400DS.Columns(2).ToString) = LCase("VA") Then
                Vacation.DataField = "Hours"
            ElseIf LCase(AS400DS.Columns(2).ToString) = LCase("OT") Then
                OT.DataField = "Hours"
            ElseIf LCase(AS400DS.Columns(2).ToString) = LCase("WH") Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(AS400DS.Columns(2))
        Next

Open in new window

0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24433527
For Each myRow As DataRow In AS400DS.Rows
                    If myRow .Item(2).ToString = "AB" Then
                Absentee.DataField = "Hours"
Next
0
 
LVL 10

Accepted Solution

by:
MaxOvrdrv2 earned 500 total points
ID: 24433539
crud, sorry, my bad, try this instead:
dim dr as DataRow
 
For Each dr In AS400DS.Rows
            If LCase(dr.Columns(2).ToString) = LCase("AB") Then
                Absentee.DataField = "Hours"
            ElseIf LCase(dr.Columns(2).ToString) = LCase("VA") Then
                Vacation.DataField = "Hours"
            ElseIf LCase(dr.Columns(2).ToString) = LCase("OT") Then
                OT.DataField = "Hours"
            ElseIf LCase(dr.Columns(2).ToString) = LCase("WH") Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(dr.Columns(2))
        Next

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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