Repeater 里放了一个CheckBox和一个Label
程序运行后显示了5个记录
我想CheckBox选择时对应的Label的值,因为他们都在一个行上。    <asp:Repeater ID="rpDicInclude" runat="server">
        <HeaderTemplate>
            <table width="100"cellpadding="0" cellspacing="0">
            </table>
                <tr>
                    <td align="left">
                        录入选项
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <hr color="Gainsboro" size="1" />
                    </td>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td align="left">
                    <asp:CheckBox ID="dicInclude" runat="server" Text='<%# Eval("DicInclude") %>' /></td>
            </tr>
           <tr>
                <td align="left">
                <asp:Label ID ="IncID"  runat="server" Text='<%# Eval("ItemID") %>'  /></td>
            </tr
            <tr>
                <td align="left">
                    <hr color="Gainsboro" size="1" />
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>

解决方案 »

  1.   

            foreach (RepeaterItem item in rpDicInclude.Items)
            {
                CheckBox chk = (CheckBox)item.FindControl("dicInclude");
                if (chk != null)
                {
                    Label lbl = (Label)item.FindControl("IncID");
                    Response.Write(lbl.Text);
                }
            }
      

  2.   

            foreach (RepeaterItem item in rpDicInclude.Items)
            {
                CheckBox chk = (CheckBox)item.FindControl("dicInclude");
                if (chk != null)
                {
                    Label lbl = (Label)item.FindControl("IncID");
                    Response.Write(lbl.Text);
                }
            }