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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:08:22+00:00 2026-05-12T17:08:22+00:00

I have 2 datatables in my ASP.NET application. I loop though both of them,

  • 0

I have 2 datatables in my ASP.NET application. I loop though both of them, and if I find a match, I delete that particular row from the outer datatable, like so:

For i As Integer = 0 To dtFixedActs.Count - 1
        For j As Integer = 0 To dtTotals.Count - 1                
            If dtFixedActs.Rows(i).Item("Activity") = dtTotals.Rows(j).Item("Activity") Then
                dtFixedActs.Rows(i).Delete()
                i += 1
                j += 1
            End If
        Next            
        dtFixedActs.AcceptChanges()
    Next

This works fine, except when the dtFixedActs contains only 1 row and a match is found in the other datatable. I get an “there is no row at position 1” error. This makes sense because with i+=1 I want to get to the next row, which is not possible in this case.

I have tried to move around the dtFixedActs.AcceptChanges command in and out of the 1st loop but to no avail. I also commented out the i+=1 line, but then I get the “Deleted row information cannot be accessed through the row.” error.

I don’t know how to program around this issue. When dtFixedActs contains more than 1 row, the problem does not occur.

Any suggestions?

  • 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-12T17:08:22+00:00Added an answer on May 12, 2026 at 5:08 pm

    Strangest thing, I seem to have solved the issue. I added a try catch exception code block like so:

    For i As Integer = 0 To dtFixedActs.Count - 1
            For j As Integer = 0 To dtTotals.Count - 1                
                Try
                    If dtFixedActs.Rows(i).Item("Activity") = dtTotals.Rows(j).Item("Activity") Then
                        dtFixedActs.Rows(i).Delete()
                        i += 1
                        j += 1
                    End If
                Catch ex As Exception
    
                End Try
    
            Next
            dtFixedActs.AcceptChanges()
        Next
    

    Everything seems to work fine now.
    Does anyone have an explanation for this, as I doubt that this is a valid solution?

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

Sidebar

Related Questions

I have developed an asp.net application that has a Gridview control. I want it
I have inherited an ASP.NET 3.5 application that relies heavily on sessions and storing
Summary We have an ASP.NET application that allows users to query a SQL Server
I'm looking to find a decent calendar control for an ASP.Net application that allows
I use yui datatable in my asp.net application... I have a link button in
I have an application that uses DataTables to perform grouping, filtering and aggregation of
okay, so i have an asp.net (C#) application and i want to add a
I have an asp.net application, and now I am using datasets for data manipulation.
We have a legacy ASP.NET web site (not web application, so I can freely
I have an ASP.NET MVC 3 app and I'm using jQuery DataTables as grid.

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.