Click here to Skip to main content
15,846,038 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys i have created dynamic checkbox ,
those controls i add it in one of my panel control.
now i want those checkbox ID and text in my button click event..
My Code is Here
private SortedList AcessingDynamicControls()
SortedList sList = new SortedList();
dTable=new DataTable();
dTable = MPostOfProperty.ReturnAmenitiesDetail("Select detail_id from CB_VIEW_Amenities");
for (int i = 0; i < dTable.Rows.Count; i++)
string ID;
bool status;
//CheckBox box = new CheckBox();
//box = this.FindControl(dTable.Rows[i]["id"].ToString()) as CheckBox;
//ID = box.UniqueID;
//status = box.Checked;
CheckBox chk = (CheckBox)PanelAmenities.FindControl(dTable.Rows[i]["detail_id"].ToString());
string s = dTable.Rows[i]["detail_id"].ToString();
ID = chk.UniqueID;
status = chk.Checked;
sList.Add(ID, status.ToString());
return sList;

ID = chk.UniqueID;
status = chk.Checked;
when the above code executed an exception generates.Object refrence not set to an instance.I think this is the pblm of postback.Please help me.How we can acess dynamic control properties
Updated 8-Mar-11 19:11pm
Sunasara Imdadhusen 8-Mar-11 23:54pm    
added code formatting!!
Jameel VM 9-Mar-11 0:04am    
Yes iam generating checkbox in load.Please help me
Jameel VM 9-Mar-11 0:06am    
how we get the Dynamic control values and ID when a button click
Sunasara Imdadhusen 8-Mar-11 23:56pm    
Are you generating checkbox from PageLoad?
Sandeep Mewara 9-Mar-11 0:11am    
Reply form OP:
Yes Iam Creating the dynamic checkbox in load

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