【问题标题】:C# RadioButtonList into TableCellsC# RadioButtonList 变成 TableCells
【发布时间】: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


    【解决方案1】:

    ListItem 直接属于 RadioButtonList(或其他一些 ASP.Net 列表控件)。您可以尝试使用普通的HtmlInputRadioButton 和指定的Name 将它们链接在一起。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      • 2022-08-05
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      • 2010-11-19
      • 2013-02-18
      相关资源
      最近更新 更多