尝试使用vb代码禁用radiobutton列表中的第一个单选按钮时出现此错误:
RadioButtonList1.Items(0).Enabled = False
这是aspx代码
<td class="TDLR">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID="SqlFollow" DataTextField="FollowDesc" DataValueField="FollowID">
</asp:RadioButtonList>
<asp:SqlDataSource ID="SqlFollow" runat="server"
ConnectionString="<%$ ConnectionStrings:SampleConnectionString %>"
SelectCommand="Select FollowID, FollowDesc FROM FollowUp WHERE FollowID > 30">
</asp:SqlDataSource>
</td>
答案 0 :(得分:1)
首先检查Items.Count:
编辑:尝试Page_PreRender
中的代码,如下所示:
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
If RadioButtonList1.Items.Count > 0 Then
RadioButtonList1.Items(0).Enabled = False
End If
End Sub