0

listitem を radiobuttonlist に動的に割り当てると、個々の listitem の 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>    
4

1 に答える 1

2

このようにアイテム コレクションを割り当てることはできません。正しい方法は次のとおりです。

  Dim items As New ListItemCollection()
     items.Add(New ListItem("hi there", "30"))


     foreach (ListItem item in items)
          rblCompanyType.Items.Add(item);
于 2013-09-18T21:01:20.823 に答える