Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am try to show the asp:Panel on the selection of asp:RadioButtonList's asp:ListItem. I am trying it many times but it is not working.

What I have tried:

protected void billOption_SelectedIndexChanged(object sender, EventArgs e)
{
if (billOption.SelectedValue == "2")
{
billaddpnl.Visible = true;
}
}
Posted
Updated 1-May-16 18:34pm
Comments
Karthik_Mahalingam 1-May-16 14:47pm    
what is the issue ?
Member 11693314 1-May-16 21:40pm    
My code is not working. When select listitem panel is not visible.
Karthik_Mahalingam 1-May-16 22:43pm    
what is your exact requirement?
Member 11693314 2-May-16 0:22am    
When user select any listitem, it shows the panel of that option.

1 solution

Try like this

C#
protected void billOption_SelectedIndexChanged(object sender, EventArgs e)
       {
           HideAllPanels(); // Hide all panels
           string selection = billOption.SelectedValue;
           switch (selection)
           {
               case "1":
                   Panel1.Visible = true;
                   break;

               case "2":
                   Panel2.Visible = true;
                   break;
                   .
                   .
                   .
               case "N":
                   PanelN.Visible = true;
                   break;

               case default:
                   HideAllPanels();
                   break;
           }
       }

       private void HideAllPanels()
       {
           Panel1.Visible = false;
           Panel2.Visible = false;
           Panel3.Visible = false;
           .
           .
           .
           PanelN.Visible = false;
       }
 
Share this answer
 
Comments
Member 11693314 3-May-16 1:11am    
I tried it but its not working. Even i put panel in UpdatePanel. But it right now not working.
I already do this for dropdownlist and it is working perfectly but for radiobuttonlist, it is not working.
Karthik_Mahalingam 3-May-16 1:22am    
add AutoPostBack="true"

<asp:RadioButtonList ID="billOption" AutoPostBack="true" runat="server" OnSelectedIndexChanged="billOption_SelectedIndexChanged">
Member 11693314 3-May-16 1:56am    
Done... I forgot this thing. U r brilliant... Thanks.
Karthik_Mahalingam 3-May-16 1:58am    
Cool, If it works Please mark it as answer to close the post.
Member 11693314 3-May-16 3:01am    
How to do this? i can't found to do this in codeproject

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900