mercredi 14 janvier 2015

Dynamic Checkbox.Checked if statement

Below is my code, the code creates a new CheckBox for each HyperLink, it then names each CheckBox with the name of the Hyperlink. I then have an IF statement which checks whether the dynamically created CheckBox has been checked. If it has, display the name of the CheckBox in a label.


However.. the label is not populating. I have tested everything and the label gets populated if i do it manually. The label has saved view state aswell. Any ideas? :)



foreach (HyperLink folder in folderList)
{
CheckBox checkbox = new CheckBox();
checkbox.Text = folder.Text.ToString();
folder.Controls.Add(check);
checkbox.EnableViewState = true;
checkbox.AutoPostBack = true;

if(check.Checked)
{
selectedFolder.Text = check.Text.ToString();
}

}




Aucun commentaire:

Enregistrer un commentaire