How do I copy or duplicate an object in .NET?
I've got a big table, where I want to repeat the header row a few time. What I tried is the following:
The result is however that only one header row shows up, at the last location. Apparently I didn't make a *real* copy of the row each time. How should I do this properly?
I've got a big table, where I want to repeat the header row a few time. What I tried is the following:
Code:
TableRow trHead = new TableRow();
TableHeaderCell th = new TableHeaderCell();
th.Text = "blah";
trHead.Cells.Add(th);
TableRow trHeadRepeat1 = trHead;
tbl.Rows.Add(trHeadRepeat1);
// Add a few data rows
TableRow trHeadRepeat2 = trHead;
tbl.Rows.Add(trHeadRepeat2);
// Add more data rows, etc
The result is however that only one header row shows up, at the last location. Apparently I didn't make a *real* copy of the row each time. How should I do this properly?