Search code examples
c#.netasp.netrepeater

find the corresponding control in repeater control


I have a Repeater control which contains a CheckBox and a lable control in each row. When a CheckBox is selected. I want to retrieve the text of the Label for the corresponding CheckBox. How to get it?


Solution

  • Add the following to the CheckBox.Checked event handler:

    CheckBox checkBox = (CheckBox) sender;
    Label label = (Label) checkBox.Parent.FindControl("LabelName");
    String labelText = label.Text;