ASP.net 创建动态单选按钮列表
我需要在表中创建动态单选按钮。我在 default.aspx(id =table1) 中有一个表,但在 .cs 中我无法访问 table1,这是第一个问题。如果我能到达它,我想创建动态单选按钮 List 。例如我想创建 8 个单选按钮列表,其中有 5 个成员。我想我用 foreach 块来做到这一点。我找到了这个代码示例:
foreach (?)
{
RadioButton radioButton = new RadioButton();
radioButton.Text = answer.Text;
radioButton.GroupName = question.Id.ToString();
radioButton.ID = question.Id + "_" + answer.Id;
TableRow answerRow = new TableRow();
TableCell answerCell = new TableCell();
TableCell emptyCell = new TableCell();
emptyCell.ColumnSpan = 2;
answerCell.Controls.Add(radioButton);
answerRow.Cells.Add(emptyCell);
answerRow.Cells.Add(answerCell);
table.Rows.Add(answerRow);
}
但我不知道实际情况。感谢您的回答...
I need to create dynamic radio button in my table.I have a table in default.aspx(id =table1) but in .cs I dont access to table1 this is frist problem. if I can reach it, I want to create dynamic radio button List . For example I want to create 8 radio button list which have 5 members. I think I do this with foreach block. I find this code samples :
foreach (?)
{
RadioButton radioButton = new RadioButton();
radioButton.Text = answer.Text;
radioButton.GroupName = question.Id.ToString();
radioButton.ID = question.Id + "_" + answer.Id;
TableRow answerRow = new TableRow();
TableCell answerCell = new TableCell();
TableCell emptyCell = new TableCell();
emptyCell.ColumnSpan = 2;
answerCell.Controls.Add(radioButton);
answerRow.Cells.Add(emptyCell);
answerRow.Cells.Add(answerCell);
table.Rows.Add(answerRow);
}
but I dont know actuallu.thanks for answering...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对表使用
runat="server"
属性:通过代码,您可以动态添加行和单元格。例如:
use
runat="server"
attribute to table:From code, you can add rows and cells dynamically. For example: