Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

 

I have a datatable that essentially works like this (containing numbers):

 

Title |Column1|Column 2|...... |Column n|TOTAL|

Name 1

Name 2

....

Name n

TOTAL

 

(ie it is essentially a 2D array with totals)

 

I want to remove each row that has a value in the total column of zero, and then remove each column that has a value in the total row of zero. (or vice versa - its irrelevant)

 

I think this is an example where an enumerator is a good idea (correct me if I am wrong) but I am unsure how to implement it. Simply iterating through the rows causes errors because when you remove one the index numbers and row/column count change and obviously it throws exceptions.

 

Any advice would be very much appreciated.

 

Cheers

TheMagician

Posted
Use the Select method of the datatable to retrieve all unwanted rows. This will return an array of datarows w/c you can remove one at a time via theDataTable.Rows.Remove method.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...