Click here to Skip to main content
15,885,872 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to create a dynamic checkbox based on selected value text from drop-downlist.

For example: The dropdownlist will have:

(test1, test2, test3) so if I am
selecting Test2
it will create a check box called test2 and so dynamically check box will get created.



this created check box will have side by 1 more linked button with few other details. and In the selected drop down list will more 5k records so whichever record wanted only will create a checkbox and go further functionalities
Posted
Comments
Sergey Alexandrovich Kryukov 6-Sep-12 3:18am    
Dynamic check box? Do you mean there is such thing as "static check box"? :-)
--SA

Hey based on your requirement you can change the below code

Drop a Place holder where u want the checkbox to appear ,

Set Autopostback property of dropdown =true

and then add the below code (for sample only) to you selectedindex changed event

C#
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
 {
     CheckBox chk = new CheckBox();
     chk.Checked = false;
     chk.Text = DropDownList2.SelectedItem.Text;
     PlaceHolder1.Controls.Add(chk);
 }
 
Share this answer
 
Comments
Lopamudra_Panda 6-Sep-12 4:07am    
Thanks a lot...if i select another item in dropdownlist it should create another checkbox.


Like : Test1 Selected in Dropdown checkbox will create called Test1
Test2 Selected in Dropdown checkbox will create called Test2 newly get added in the palceholder. New check box on each selection of dropdown.

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