ICollection method does not work as expected

Using #, WPF

Starting from a text file I need to:
1. Import this text file into a Data Table
2. Browse the data rows and in some case add an extra row
3. Convert this DT to a List
4. Display either the list or the DT in a datagrid (via a button click)

My code works well in step 1 and 4 but skip the 2 and 3
Unable to find why steps 2 and 3 are ignored

Here comes the C# method
 private ICollection CreateDataSource_vNodes() // vNodes
        {
            //Create new DataTables and Rows
            DataTable dt_vNodes = new DataTable();
            DataRow dr;

            // Create columns with headers
            dt_vNodes.Columns.Add("IdNumber", typeof(int));
            dt_vNodes.Columns.Add("Position", typeof(string));

            //Read the file vNodes_Capture.txt and, for each line, create a new row in dt_vNodes
            string txtDataBase = "vNodes_Capture.txt";

            foreach (string Line in File.ReadLines(txtDataBase))
            {
                //Split lines at delimiter ';''
                //Create new Row
                dr = dt_vNodes.NewRow();

                //IdNumber =
                dr[0] = Line.Split(';').ElementAt(0);

                //Position =
                dr[1] = Line.Split(';').ElementAt(1);

                //Add the row we created
                dt_vNodes.Rows.Add(dr);
            }

            // Check values in column "Position" and add virtual bones if necessary    

            List<DataRow> rows = dt_vNodes.AsEnumerable().ToList();
            foreach (DataRow drow in rows)
            {
                int currentidnumber = Convert.ToInt32(drow["IdNumber"]);
                string currentposition = drow["Position"].ToString();
                if (currentposition.ToLower() == "upspine") // convertie en minuscules
                {
                    dt_vNodes.Rows.Remove(drow); // delete row with upspine
                    dt_vNodes.Rows.Add(new object[] { currentidnumber, "LeftShoulder" });
                    dt_vNodes.Rows.Add(new object[] { currentidnumber, "RightShoulder" });
                }
                else if (currentposition.ToLower() == "pelvis") //convertie en minuscule
                {
                    dt_vNodes.Rows.Remove(drow); // delete row with pelvis 
                    dt_vNodes.Rows.Add(new object[] { currentidnumber, "LeftHip" });
                    dt_vNodes.Rows.Add(new object[] { currentidnumber, "RightHip" });
                }
                else
                {
                    dt_vNodes.Rows.Add(new object[] { currentidnumber, currentposition });
                }

            }

            // Converting the DT in a List<string> for further use

            foreach (DataRow drow in rows)
            {
                BonesRealVirtualS.Add(drow["Position"].ToString());
            }

            //Return Dataview that populates the datagrid ItemsSource
            DataView dvN = new DataView(dt_vNodes);
            dgBB.ItemsSource = BonesRealVirtualS;
            return dvN;

        }

Open in new window


and the xaml line
<DataGrid Name="dgbonesRV" HorizontalAlignment="Left" Margin="41,64,0,0" VerticalAlignment="Top" Height="214" Width="194"/>

Open in new window


text file is attached
vNodes_Capture.txt
PaulagierResearch DirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karrtik IyerSoftware ArchitectCommented:
Hi Paul,
Few questions :
1) can you please specify the type of BonesRealVirtualS, what it is?
2) is dgBB a list view or something else?
3) can you please publish your expected output based on the input of the text file you attached in your question?
4) Also in else case below I'm not sure we need to add a new row since this is already present in the data table.
else { dt_vNodes.Rows.Add(new object[] { currentidnumber, currentposition }); }
Thanks,
Karrtik
PaulagierResearch DirectorAuthor Commented:
Hi Karrtik,
1.
        List<string> BonesRealVirtualS = new List<string>();
2.
        dgBB is a datagrid
3.
        expected output: two colums , identical to the txt file i.e. "IdNumber" and "position"
4.
        Don't know , i' m a newbie in that world !!
PaulagierResearch DirectorAuthor Commented:
I have changed the business model of the app so I don't need the solution anymore
thanks anyway Karrtik

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karrtik IyerSoftware ArchitectCommented:
No problems Paul, let me know if you need any further help.
PaulagierResearch DirectorAuthor Commented:
I have changed the way data are stored (avoiding using data table )
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.