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

  • Home
  • SEARCH
  • 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 7174359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:01:26+00:00 2026-05-28T16:01:26+00:00

I have DataTable with the following columns: ClientID date numberOfTransactions price ClientID is of

  • 0

I have DataTable with the following columns:

ClientID date numberOfTransactions price

ClientID is of type string and I need to ensure that its contents include “A-” and “N6” for every value in the table.

I need to delete all rows from the DataTable where this first column (ClientID) does not contain both “A-” and “N6” (some totals and other unnecessary data). How can I select and delete these rows specifically from the DataTable?

I know this:

foreach (DataRow row in table.Rows) // Loop over the rows.
    {

        //Here should come part "if first column contains mentioned values
    }

I also know this

If (string.Contains("A-") == true &&  string.Contains("N6") == true)

{
//Do something
}

I need help how to implement this for first column of each row.

  • 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-28T16:01:28+00:00Added an answer on May 28, 2026 at 4:01 pm

    Try this:

    EDIT: Totally messed up that last line, so if you tried it, try it now that I made it not stupid. =)

    List<int> IndicesToRemove = new List<int>();
    DataTable table = new DataTable(); //Obviously, your table will already exist at this point
    foreach (DataRow row in table.Rows)
    {
       if (!(row["ClientID"].ToString().Contains("A-") && row["ClientID"].ToString().Contains("N6")))
          IndicesToRemove.Add(table.Rows.IndexOf(row));
    }
    IndicesToRemove.Sort();
    for (int i = IndicesToRemove.Count - 1; i >= 0; i--) table.Rows.RemoveAt(IndicesToRemove[i]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following DataTable dt = new DataTable(); dt.Columns.Add(col1, typeof(string)); dt.Columns.Add(col2, typeof(string)); dt.Rows.Add(1,
I have a DataTable that has a string type column filled with valid numeric
I have converted my Datatable to json string use the following method... public string
I have the following code that serializes a DataTable to XML. StringWriter sw =
I have a DataTable that has a boolean column called [Invalid]. I need to
I have the DataTable with following columns: id, Name, Description, ParentId and would like
I have a DataTable with the following columns: id msisdn status another_column And a
If I have a DataTable userwidget , which has the following columns: process_id, emp_num,
I have a DataTable called test_results with the following columns: test_results_id student_id subject score
I have the following piece of code: DataRow CreateRow(DataTable dt, string name, string country)

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.