1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

List problem ... need a second set of eyes....

Discussion in 'C#' started by Zinderin, Aug 28, 2010.

  1. Zinderin

    Zinderin New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    Below is working code from my application.

    All I'm pulling back from the table is is IDX and an associated string.

    ls is a List of the same class tmpINC is an instance of.

    When I test tmpINC before adding it to the list, the data in IDX and Name is correct.

    However in the loop I do after (to check the data with the MessageBox.Show) every record is the same (the last record added).

    What am I missing here.

    // Fill the List ...
    if (ds.Tables[0].Rows.Count > 0)
    for (int x = 0; x < ds.Tables[0].Rows.Count; x++)
    tmpINC.IDX = int.Parse(ds.Tables[0].Rows[x][0].ToString());
    tmpINC.Name = ds.Tables[0].Rows[x][1].ToString();

    for (int x = 0; x < ls.Count; x++ )
    MessageBox.Show(ls[x].IDX.ToString() + "\n" + ls[x].Name);
    Thanks for looking guys.

Share This Page