I'm trying to add radio buttons to my Table.
The problem is that I'm using a RadioButtonList to hold radios and an ListItem cant be added to a cell for some reason? Is my code totally of or is there another way to handle this in .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;
}
A ListItem belongs directly in a RadioButtonList (or some other ASP.Net list control). You could try to use plain HtmlInputRadioButton with a specified Name to link them together.