Here's what I want to do: I created an ASP:Table and now I want to add rows dynamically using TableRow. Thing is I want to have 3 pics on every row, which means that there must be a new tablerow every time the integer iced is a number that can be divided by 3 (iced % 3).
The code below would be simple and straightforward, but one of the problems with C# is that it doesn't recognize the TableRow tRow = new Table(); outside if {}, and if I declare TableRow outside the if, all I get is one tablerow for all the pictures (if it is declared above while{} ), or a tablerow for all pics with number divisible by 3 (if declared inside the while but outside the if).
How do I solve this problem?
while (myReader.Read())
{
if (iced ==1 || (iced%3) == 0)
{
contents = contents + iced.ToString();
Label1.Text = contents.ToString();
TableRow tRow = new TableRow();
value1.Rows.Add(tRow);
}
TableCell tCell = new TableCell();
tCell.Text = myReader.GetString(1);
tRow.Cells.Add(tCell);
iced++;
}
__________________________________________________ ___________________
http://www.carbotek.org
Last edited by rpcarnell : 04-12-2007 at 03:14 AM.
|