Je suis en train de créer dynamiquement une table avec des boutons radio, des zones de texte et des boutons sur chaque ligne uniquement en fonction de la question à gauche du TableRow avec deux TableCells.Comment ajouter dynamiquement des boutons radio, des texboxes et des boutons dans une table par code?
Jusqu'ici, j'ai pu ajouter les questions à la gauche du TableRow. Maintenant, j'ai du mal à remplir le bon côté.
Quelqu'un peut-il m'aider?
J'ai le code ci-dessous:
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);
}
S'agit-il d'ASP.NET WebForms ou de Winforms? – tsimbalar
Je pense que c'est un formulaire ASP.Net, car il y a une ligne "formCell.Attributes.CssStyle.Add (" border "," solid ");" – Kay
@Kay: oh oui, c'était une question stupide :-) – tsimbalar