Reputation: 1
I am getting this error while trying to disable the first radio button on the radiobutton list using the vb code:
RadioButtonList1.Items(0).Enabled = False
Here is the aspx code
<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>
Upvotes: 0
Views: 489
Reputation: 7943
Check the Items.Count first:
EDIT : Try the code in Page_PreRender
like below:
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
Upvotes: 1