【发布时间】:2010-10-20 06:26:56
【问题描述】:
我正在尝试根据带有两个 TableCell 的 TableRow 左侧的问题,在每一行上动态创建一个带有单选按钮、文本框和按钮的表格。
到目前为止,我能够将问题添加到 TableRow 的左侧。现在,我很难填写它的右侧。
有人可以帮我吗?
我有以下代码:
private void DesignQuestionnaire(string[] questionList, Label question, RadioButtonList answerChoices, RadioButton choices, TextBox textAnswer, Button save, Button cancel)
{
Table formTable = new Table();
TableRow formRow;
TableCell formCell;
for (int row = 0; row < questionList.Length; row++ )
{
formRow = new TableRow();
formTable.Rows.Add(formRow);
for (int col = 0; col < 2; col++ )
{
formCell = new TableCell();
//formCell.Attributes.CssStyle.Add("border", "solid");
if (col == 1)
{
formCell.ID = "A" + row.ToString();
formCell.Controls.Add(choices);
}
else
{
formCell.ID = "Q" + row.ToString();
formCell.Text = questionList.GetValue(row).ToString();
}
formRow.Cells.Add(formCell);
}
}
Controls.Add(formTable);
}
【问题讨论】:
-
是 ASP.NET WebForms 还是 Winforms ?
-
我认为这是 ASP.Net 表单,因为有一行 "formCell.Attributes.CssStyle.Add("border", "solid");"
-
@Kay :哦,是的,这是一个愚蠢的问题 :-)
标签: c# radio-button tablerow tablecell