Hi there, I have a similar issue. I'm attempting to load some SQL data to a dynamic table, all the data loads fine, the problem is formatting the layout of two particular cells. I understand whats going on, but cannot find a solution. What i'm attempting to do is for each text item in this particular db (loaded into an array) list the text, and beneath each item, display a button. The problem is it will only do this correct format for the last item, as it is getting overwritten. So I think what I need to be doing is appending to this cell somehow, thanks in advance for any further help. As you will see its not the best of code atm but its been mashed and mixed so many times, any questions about my code will be quickly responded to.
Pete.
CODE
for (int i = 0; i < 4; i++)
{
TableRow tr = new TableRow();
tr.BorderWidth = 1;
TableRow r = new TableRow();
r.BorderWidth = 1;
TableCell tc = new TableCell();
tc.BorderWidth = 1;
TableCell tc2 = new TableCell();
tc2.BorderWidth = 1;
TableCell tcb = new TableCell();
tcb.BorderWidth = 1;
tc2.Width = 400;
Label l = new Label();
l.Font.Bold = true;
Label l2 = new Label();
if (!(cemsDescArray[f].Equals(0)))
{
if (i.Equals(0))
{
l.Text = "CEMS ID: ";
l2.Text = cemsDescArray[a].ToString();
a++;
tc.Controls.Add(l);
tc2.Controls.Add(l2);
r.Cells.Add(tc);
r.Cells.Add(tc2);
}
if (i.Equals(1))
{
l.Text = "Summary: ";
String x = (string)descArray[b];
String newT = x.Replace("##APO##", "\'");
l2.Text = newT;
b++;
tc.Controls.Add(l);
tc2.Controls.Add(l2);
r.Cells.Add(tc);
r.Cells.Add(tc2);
}
if (i.Equals(2))
{
l.Text = "Description: ";
String xx = "";
newX = "";
tc.Controls.Add(l);
r.Cells.Add(tc);
foreach (String str in extDescArray)
{
xx += str + "<br/><br/>";
newX = xx.Replace("##APO##", "\'");
l2.Text = newX;
//tc2 = new TableCell();
editInfo = new Button();
editInfo.Attributes.Add("AutoPostBack", "true");
editInfo.Text = "Edit Description";
editInfo.Click += new EventHandler(editInfo_Click);
tc2.Controls.Add(l2);
tc2.Controls.Add(editInfo);
r.Cells.Add(tc2);
}
c++;
}
if (i.Equals(3))
{
l.Text = "Solution: ";
String xxx = "";
newTe = "";
tc.Controls.Add(l);
r.Cells.Add(tc);
foreach (String str in solutionsArray)
{
xxx += str + "<br/><br/>";
newTe = xxx.Replace("##APO##", "\'");
l2.Text = newTe;
//tc2 = new TableCell();
editSolution = new Button();
editSolution.Attributes.Add("AutoPostBack", "true");
editSolution.Text = "Edit Solution";
editSolution.Click += new EventHandler(editSolution_Click);
tc2.Controls.Add(l2);
tc2.Controls.Add(editSolution);
r.Cells.Add(tc2);
}
d++;
f++;
}
tc.HorizontalAlign = HorizontalAlign.Left;
tc.VerticalAlign = VerticalAlign.Top;
//r.Cells.Add(tc);
//r.Cells.Add(tc2);
table1.Rows.Add(r);
}
}
form1.Controls.Add(table1);