Search code examples
asp.netdatarepeater

Use data in repeater when Checkbox is check in ASP.net


I have a repeater for showing my data . this repeater showing 2 field that one of feild is checkBox Control and other is a lable.

NOW , how can I understand text of lable when the checkBox is Checked?

I want to see text of lable in evry row that the CheckBoxes is checksd.

how do I do?

I use LINQtoSQL for get and set data from database


Solution

  • Page...

                 <asp:CheckBox ID="chkBoxID" runat="server" OnCommand="doSomething_Checked" CommandArgument="<%# Some Binding Information%>"
                    CommandName="NameForArgument">
                 </asp:CheckBox>
    

    Code Behind...

    protected void doSomething_Checked(object sender, CommandEventArgs e) {
    
                    CheckBox ctrl = (CheckBox)sender;
                    RepeaterItem rpItem = ctrl.NamingContainer as RepeaterItem;
                    if (rpItem != null) {
                        CheckBox chkBox = (LinkButton)rpItem.FindControl("chkBoxID");
                        chkBox.DoSomethingHere...
                 }
            }