当我将listitems动态分配给radiobuttonlist时,各个listitems的value属性等于该listitem的文本值。 简而言之,我的值不用于属性值。
Dim items As New ListItemCollection()
items.Add(New ListItem("hi there", "30"))
rblCompanyType.DataSource = items
rblCompanyType.DataBind()
<asp:RadioButtonList ID="rblCompanyType" Width="490" RepeatColumns="2" RepeatDirection="Vertical" runat="server"></asp:RadioButtonList>
<table style="width:490px;" id="CPHCenter_rblCompanyType">
<tbody><tr>
<td>
<input type="radio" value="hi there" name="ctl00$CPHCenter$rblCompanyType" id="CPHCenter_rblCompanyType_0">
<label for="CPHCenter_rblCompanyType_0">hi there</label>
</td>
</tr>
</tbody>
</table>
答案 0 :(得分:2)
您不能像这样分配项目集合。正确的方法是:
Dim items As New ListItemCollection()
items.Add(New ListItem("hi there", "30"))
foreach (ListItem item in items)
rblCompanyType.Items.Add(item);