c# - How to get checked checkbox value which is created dynamically in button click event -
i having checkboxes created dynamically in page_load event , put in panel.
foreach (datarow dr in column_ds.rows) { column_checkbox = new checkbox(); column_checkbox.text = (string)dr["column_name"]; columnpanel1.controls.add(column_checkbox); }
now want checked check box values in btn_click event. ideas? tried,
columnpanel1.findcontrol("column_checkbox");
and
checkbox cb=(checkbox)findcontrol("column_checkbox"); if (column_checkbox.checked) { } { string name = column_checkbox.text; }
on click event of button, can implement below logic.
protected void btn_click(object sender, eventargs e) { foreach(var row in columnpanel1.rows) { var tempchkbx= row.controls[0] checkbox; if(tempchkbx.ischecked) { //write code } } }
Comments
Post a Comment