G
Grant
Hi,
Ive got this loop within a loop and Im trying to build a table. Problem is
when I exit the 2nd foreach loop (having created a new row) I cant add the
new row because it isnt in scope anymore. Basically I have this custom
arraylist containing a name property which has multiple attributes. I loop
through the values and foreach value I do a 2nd loop to get all the values
attributes. So I guess my question is how would I build a table with 2
columns? 1st column containing the value and the 2nd column containing the
values? so it should look something like:
property1 | property attribute
| property attribute
| property attribute
Property2 | property2 attribute
Property2 | property2 attribute
etc...
Heres my code:
-----------------------------------------------------
foreach ( CustomArrayList _object in _GlobalPropertyValues )
{ //Create a table cell for user names
usernameCell = new TableCell();
usernameCell.BorderStyle = BorderStyle.Solid;
usernameCell.Text = _object.propertyName;
foreach ( string _propertyName in _object )
{ //Create another table cell for user AD paths
userContainerCell = new TableCell();
userContainerCell.BorderStyle = BorderStyle.Solid;
userContainerCell.Text = _propertyName;
//Construct the table rows
newRow = new TableRow();
newRow.Cells.Add( userContainerCell );
tblResults.Rows.Add( newRow );
}
//Add the cells to the table row
newRow = new TableRow();
newRow.Cells.Add( usernameCell );
//newRow.Cells.Add( userContainerCell );
tblResults.Rows.Add( newRow );
}
-----------------------------------------------------
The code above produces a single column table.
Thanks for any help on this!
Cheers,
Grant
Ive got this loop within a loop and Im trying to build a table. Problem is
when I exit the 2nd foreach loop (having created a new row) I cant add the
new row because it isnt in scope anymore. Basically I have this custom
arraylist containing a name property which has multiple attributes. I loop
through the values and foreach value I do a 2nd loop to get all the values
attributes. So I guess my question is how would I build a table with 2
columns? 1st column containing the value and the 2nd column containing the
values? so it should look something like:
property1 | property attribute
| property attribute
| property attribute
Property2 | property2 attribute
Property2 | property2 attribute
etc...
Heres my code:
-----------------------------------------------------
foreach ( CustomArrayList _object in _GlobalPropertyValues )
{ //Create a table cell for user names
usernameCell = new TableCell();
usernameCell.BorderStyle = BorderStyle.Solid;
usernameCell.Text = _object.propertyName;
foreach ( string _propertyName in _object )
{ //Create another table cell for user AD paths
userContainerCell = new TableCell();
userContainerCell.BorderStyle = BorderStyle.Solid;
userContainerCell.Text = _propertyName;
//Construct the table rows
newRow = new TableRow();
newRow.Cells.Add( userContainerCell );
tblResults.Rows.Add( newRow );
}
//Add the cells to the table row
newRow = new TableRow();
newRow.Cells.Add( usernameCell );
//newRow.Cells.Add( userContainerCell );
tblResults.Rows.Add( newRow );
}
-----------------------------------------------------
The code above produces a single column table.
Thanks for any help on this!
Cheers,
Grant