0

我想知道为什么 .Net Table 行被添加到同一行而不是多行?

具体问题在于这段代码:

this.table.Rows.AddAt(0,labels);
this.table.Rows.AddAt(1,fields);
this.table.Rows.AddAt(2,submits);

表是一个 WebControls.Table
标签、字段和提交是 TableRows
,它们都包括 TableCells。

但是当我在浏览器中查看它时,它表示为 <tr>“所有行和列”

</tr>

然后两个空

<tr></tr><tr></tr>

标签..?

因此,它添加了单元格和行的所有内容,甚至添加了三行,但由于某种原因,它将所有信息放在第一个

<tr> 标签。

任何想法我做错了什么?

<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>
4

1 回答 1

1

您可以通过传递单元容器尝试使用此代码

/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);
于 2012-09-11T13:43:34.127 回答