Repeater Control Words of Wisdom
Non-mental note to self.
When using the .NET Repeater Control in which there is a child CheckBox or RadioButton present to allow for data items to be selected, ensure that autopostback = true for the child control you are using.
If autopostback is not true, the value of the Checked property will always be false when the RadioButton or Checkbox has been selected and you come to use FindControls in order to determine the state of your child control:
When using the .NET Repeater Control in which there is a child CheckBox or RadioButton present to allow for data items to be selected, ensure that autopostback = true for the child control you are using.
If autopostback is not true, the value of the Checked property will always be false when the RadioButton or Checkbox has been selected and you come to use FindControls in order to determine the state of your child control:
protected void Button1_Click(object sender, EventArgs e)Also ensure that string passed into the "FindControl" function matches the name of the control you are looking for. Not that I'd be foolish enough to make such an elementary typo, of course.
{
bool CheckedValue;
foreach (RepeaterItem Item in Repeater1.Items)
{
CheckBox CB = (CheckBox)Item.FindControl("MyCheckBox");
CheckedValue = CB.Checked;
}
}
Labels: Code Snippets, Web Development
0 Comments:
Post a Comment
<< Home