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 6078199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:48:22+00:00 2026-05-23T10:48:22+00:00

I have 100 rows in a DataGridView. I then remove each row as shown

  • 0

I have 100 rows in a DataGridView. I then remove each row as shown below but as it loops around the ID is coming in as 0,2,4,6,8 and therefore its removing only even rows. What’s going on?

                foreach (DataGridViewRow row in dgvData.Rows)
                {
                    try
                    {
                        if (row.IsNewRow)
                            continue;

                        string PalletID = row.Cells[1].Value.ToString();
                        string Location = row.Cells[2].Value.ToString();


                        dgvData.Rows.Remove(row);
                        AddToList(PalletID + " located in " + Location + " was uploaded");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error Uploading Data");
                        AddToList("Error uploading data " + ex.Message);
                        continue;
                    }
                }
  • 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-05-23T10:48:22+00:00Added an answer on May 23, 2026 at 10:48 am

    I believe as you loop through the grid and delete the current row, its messing up with the index of the grid which as of now would be causing the rows to shift a level up. So as you proceed further to the next row it has already moved to the index wherein you deleted the row.

    Your best bet would be use a for loop and run it reverse and this should work out fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of of more then 100 rows. each row consist of
Ok so say I have 100 rows to insert and each row has about
/select/?q=*:*&rows=100&facet=on&facet.field=category I have around 100 000 documents indexed. But I return only 100 documents
I have around 100 rows of text that I want to tokenize, which are
I have 1000 rows of data but need to only display 100 rows at
i have a list 1 column and 100 rows each with a number the
I have some 50 pages of html which have around 100-plus rows of data
I have datagridview that has 25 to 100 rows. I am performing a task
I'm currently have around 100 rows in a table on my website, which include
I currently have several rows (say around 100 for args sake) in a table,

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.