jayz jayz - 1 year ago 108
Vb.net Question

Change visibility of RadioButton item from code behind VB.NET

I have a

ASP.NET radiobutton
in my aspx web page and I'm using VB as my programming language.

<asp:RadioButtonList ID="rdoRecStatus" runat="server" Width="152px" CssClass="normalText"
<asp:ListItem Value="1">Open</asp:ListItem>
<asp:ListItem Value="0">Closed</asp:ListItem>

I want to change the visibility of the 2nd radio button <
asp:ListItem Value="0">Closed</asp:ListItem>
from a button click.

I tried using
rdoRecStatus.Items[1].Visible = True/False
to the above task and it shows an error.

Con you please tell me the right way to do the above task in
. Thank you in advance.

Answer Source

Unfortunately There is no Visible properties for <asp:ListItem>, So we need to Look for some alternatives here to achieve this target.

Method 1 : Depend css to do this function like the following

 rdoRecStatus.Items(1).Attributes.Add( "hidden", "hidden" )

Method 2 : Remove that particular Item From the List:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download