Duplicating asp:Table object with VB (ByVal, not ByRef)
Posted on 2011-09-12
I have an asp:Table object (PlanTable) which is set dynamically. And I have a Table shared variable (_Plan2). What I want is to duplicate one into another. I've tried many things:
1) _Plan2 = PlanTable (seems to work, but doesn't load anything).
2) For a = PlanTable.Rows.Count - 1 To 0 Step -1
Next (doesn't work. Adds the rows, but removes from the other table)
3) Protected Sub DuplicateTables(ByVal T1 As Table, ByRef T2 As Table)
For a = T1.Rows.Count - 1 To 0 Step -1
End Sub (doesn't work either. I thought by sending one of the tables with ByVal argument, it wouldn't be changed, but it is)
I don't know how I should do this correctly. I've thought about cycling through the cells as well, creating a new TableCell variable and copying the attributes one by one, but not only is that kinda extensive (there are quite a few number of cells I have to copy), some cells actually have controls inside them. Some may have Labels, some Buttons and some Textboxes and MaskedEditValidators. To use a loop for the cells, I would have to check for controls and create copies of them, even without knowing which type they are.
Anyway, anyone have a good suggestion for this? My biggest problem is leaving the source table intact (especially because, later in the code, they switch places). Seeing as I already have the Sub created, we might use the above coded DuplicateTables(ByVal T1 As Table, ByRef T2 As Table).