Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8064341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:20:17+00:00 2026-06-05T11:20:17+00:00

What is wrong? Basically want to extract each code in each row of table

  • 0

What is wrong?
Basically want to extract each code in each row of table “Service”
And if it is equal to specific text then set each corresponding row with matching text.

foreach (DataRow code in dsAuthors.Tables["Service"].Rows)
{

   for (int i = 0; i < dsAuthors.Tables[1].Rows.Count; i++)
    {

        if (code[1].ToString() == "01")
        {
            Shipment.Rows[i][0] = "Service 1";
        }
        else if (code[1].ToString() == "02")
        {
            Shipment.Rows[i][0] = "Service 2";
        }
        else if (code[1].ToString() == "03")
        {
            Shipment.Rows[i][0] = "Service 3";
        }
    }
}

It just fills all rows in with Service 1 but i don’t want it to.

Sorry was NOT meant to have both tables be the same i have updated the code to be more accurate i believe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:20:19+00:00Added an answer on June 5, 2026 at 11:20 am

    You’re iterating over the list of rows twice. You’re reading data from the variable from the outer loop, and writing to the index from the inner loop. It’s writing “Service 1” to all rows because the last row is “01”, and the inner loop writes that to all rows.

    Try this instead:

    var Service = dsAuthors.Tables["Service"];
    for (int i = 0; i < Service.Rows.Count; i++)
    {
        if (Service.Rows[i][1].ToString() == "01")
        {
            Shipment.Rows[i][0] = "Service 1";
        }
        else if (Service.Rows[i][1].ToString() == "02")
        {
            Shipment.Rows[i][0] = "Service 2";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've Googled for this but must be using the wrong keywords. Basically I want
My code below won't compile. What am i doing wrong? I'm basically trying to
I have this perl code below, basically want to loop through these 2 files.
Basically i want to merge two Iqueryable to one Iqueryable and then return the
I want basically the same as jquery select image a row of images that
I am having problems creating a table in python. Basically I want to build
Or am I thinking about this wrong? Basically, I want to be able to
I have a problem with the following javascript code. Basically I want to run
Can someone suggest what I am doing wrong? Basically I have a List Items,
Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.