This is a migrated thread and some comments may be shown as answers.

Report not synched up with array in code behind

1 Answer 27 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Richard M
Top achievements
Rank 1
Richard M asked on 05 Jan 2011, 11:22 PM
I created a Report1 and it code behind added this code after InitializeComponent():

            // create and populate an array of Coffee objects
            Coffee[] coffees = new Coffee[]
            {
            new Coffee("Latte", 1),
            new Coffee("Mocha", 2),
            new Coffee("Dark Roast", 3)
            };
            // assign the array to the DataSource
            this.DataSource = coffees;

and added this class:
    public class Coffee
        {
            private string _name;
            private int _id;
            public Coffee (string name, int id)
            {
                _name = name;
                _id = id;
            }
            public string Name
            {
                get
                {
                    return _name;
                }
                set
                {
                    _name = value;
                }
            }
            public int ID
            {
                get
                {
                    return _id;
                }
                set
                {
                    _id = value;
                }
            }
        }

I added two textboxes to Report1.  One uses the expression =id  and the other uses =name.  When I add Report1 to a web page using a ReportViewer, it only creates 2 records, both show id = 1, and name = Latte.

1 Answer, 1 is accepted

Sort by
0
Richard M
Top achievements
Rank 1
answered on 05 Jan 2011, 11:47 PM
I figured out that I made a stupid mistake.  All of my textboxes were in the header, and not in the detail section.  Problem is fixed.
Tags
General Discussions
Asked by
Richard M
Top achievements
Rank 1
Answers by
Richard M
Top achievements
Rank 1
Share this question
or