我试图设置我从后面的代码生成的单选按钮的名称。我不能让它工作。有什么想法吗?
我是怎么做到的:
protected void repProductsDatabound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
Enums.ProductCode product = (Enums.ProductCode)e.Item.DataItem;
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell buttonCell = new HtmlTableCell();
HtmlInputButton btn = new HtmlInputButton("radio");
btn.Name = "productsRadioGroup";
// btn.ServerClick += onProductSelectionChanged;
buttonCell.Controls.Add(btn);
row.Controls.Add(buttonCell);
HtmlTableCell ProductCell = new HtmlTableCell();
ProductCell.InnerText = product.ToString().Replace("_", " ");
row.Controls.Add(ProductCell);
e.Item.Controls.Add(row);
}
}
结果
<td><input name="ctl00$MainContent$repProducts$ctl01$ctl02" type="radio" /></td>
<td>Be Business</td>
</tr>
<tr>
<td><input name="ctl00$MainContent$repProducts$ctl02$ctl02" type="radio" /></td>
<td>Be BusinessLite</td>
</tr>
<tr>
<td><input name="ctl00$MainContent$repProducts$ctl03$ctl02" type="radio" /></td>
<td>Be BusinessPro</td>
</tr>
答案 0 :(得分:0)
看起来你无法在转发器中设置单选按钮的名称。它是一个已知的错误http://support.microsoft.com/default.aspx?scid=kb;en-us;Q316495