Reputation: 770
I am wondering why .Net Table rows are being added to the same line instead of multiple lines?
Specifically the problem is with this code:
this.table.Rows.AddAt(0,labels);
this.table.Rows.AddAt(1,fields);
this.table.Rows.AddAt(2,submits);
table is a WebControls.Table
labels, fields and submits are TableRows
which all include TableCells.
But when I look at it in the browser it is represented like < tr > "all the rows and columns"
< /tr >
and then two empty
< tr > < /tr > < tr > < /tr >
tags..?
So it adds all the content of the cells and the rows and it even adds three rows but for some reason it puts all the info in the first
< tr > tag.
Any ideas what I'm doing wrong?
<table border="0">
<tr>
<td><span>please enter the title of the interaction here</span></td><td><span>please enter the description of the interaction here</span></td><td><span>please select the impact level of the interaction here</span></td><td><span>please select the urgency level of the interaction here</span></td><td><span>please enter the contact of the interaction here</span></td><td><input name="ctl00$PlaceHolderMain$ctl00$ctl06" type="text" value="one" /></td><td><input name="ctl00$PlaceHolderMain$ctl00$ctl07" type="text" value="two" /></td><td><select name="ctl00$PlaceHolderMain$ctl00$ctl08">
<option selected="selected" value="1">Low</option>
<option value="2">Medium</option>
<option value="3">High</option>
</select></td><td><select name="ctl00$PlaceHolderMain$ctl00$ctl09">
<option selected="selected" value="1">Low</option>
<option value="2">Medium</option>
<option value="3">High</option>
</select></td><td><input name="ctl00$PlaceHolderMain$ctl00$ctl10" type="text" value="con" /></td><td rowspan="3"><input type="submit" name="ctl00$PlaceHolderMain$ctl00$ctl11" value="Create Interaction" /></td><td rowspan="2"><span>No interactions created yet</span></td>
</tr><tr>
</tr><tr>
</tr>
</table>
Upvotes: 0
Views: 327
Reputation: 29000
You can try with this code, by passing cell container
/adding first row
TableRow row1 = new TableRow();
//adding first cell
TableCell cell1 = new TableCell();
//adding label
Label text1 = new Label();
text1.Text = "Just test";
cell1.Controls.Add(text1);
row1.Controls.Add(cell1);
table1.Controls.Add(row1);
Upvotes: 1