Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
Can anyone help me in replacing a control with another (like replacing combobox with radio button) in runtime.
Posted
Comments
sagar wasule 4-Jun-12 7:47am    
Can you please explain ur doubt a bit more in detail ??
sagar wasule 4-Jun-12 7:53am    
There has to be any event which will be fired. I mean on which operation do u need to change combobox to radio button ?? just make combo box invisible and radio button visible
Prasad_Kulkarni 4-Jun-12 8:09am    
Not clear.

1 solution

yes you can but in 2 condition:
first, the controls have to exists in a parent control like parent!
second, you should have their ID!
C#
protected void Page_Load(object sender, EventArgs e)
        {
            Panel1.Controls.Remove(Button1);
            RadioButton rdbtn = new RadioButton();
            rdbtn.Checked = false;
            rdbtn.ID = "rdbtn";
            rdbtn.Text = "your aswer?";
            Panel1.Controls.Add(rdbtn);
        }

explain of my code:
I have a button in a panel control, and in page_load method i remove button , and
make a new checkbox control , and set it to these values and add this control to panel!
 
Share this answer
 

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