【发布时间】:2011-09-04 20:27:21
【问题描述】:
我正在尝试将单选按钮添加到我的表格中。
问题是我正在使用 RadioButtonList 来保存收音机,并且由于某种原因无法将 ListItem 添加到单元格中?我的代码是完全属于还是有其他方法可以在 .net 中处理?
private TableRow generateCells(String domainName)
{
TableRow row = new TableRow();
Label dName = new Label();
dName.Text = domainName;
RadioButtonList radioList = new RadioButtonList();
ListItem sunriseA = new ListItem();
sunriseA.Value = Price_Types.SUNRISE_ONE.ToString();
radioList.Items.Add(sunriseA);
ListItem sunriseB = new ListItem();
sunriseB.Value = Price_Types.SUNRISE_TWO.ToString();
radioList.Items.Add(sunriseB);
ListItem landrush = new ListItem();
landrush.Value = Price_Types.LANDRUSH.ToString();
radioList.Items.Add(landrush);
ListItem general = new ListItem();
general.Value = Price_Types.GENERAL.ToString();
radioList.Items.Add(general);
row.Cells.Add(addCell(dName));
// this is not working
row.Cells.Add(addCell(sunriseA));
row.Cells.Add(addCell(sunriseB));
row.Cells.Add(addCell(landrush));
row.Cells.Add(addCell(general));
return row;
}
private TableCell addCell(Control c)
{
TableCell cell = new TableCell();
cell.Controls.Add(c);
return cell;
}
【问题讨论】:
标签: c# webforms controller radiobuttonlist