在asp.net中使用转发器中的复选框 [英] using check boxes in repeater in asp.net

查看:82
本文介绍了在asp.net中使用转发器中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何取消选中中继器数据控件中的所有复选框(而不是选中的复选框)?

how to uncheck all check boxes in repeater data control , other than the one being checked?

推荐答案

jQuery可以在客户端非常简单地做到这一点. br/>
但是,如果要在后面的代码中执行此操作:

jQuery could do that on the client side very simply.

However, if you want to do it in code behind:

<ItemTemplate >
    <asp:CheckBox ID="CheckBox1" runat="server"  AutoPostBack="True"

        oncheckedchanged="RepeaterCheckBox_CheckedChanged"/>







protected void RepeaterCheckBox_CheckedChanged(object sender, EventArgs e)
{
    // for each data row
    foreach (RepeaterItem RE in Repeater1.Controls)
    {
        // for each control in the data row
        foreach (Control C in RE.Controls)
        {
            CheckBox CB = C as CheckBox;

            if ((CB != null) && (CB != sender))
                CB.Checked = false;
        }
    }
}


虽然没有开箱即用的功能,但是可以使用一些javascript轻松完成,为此,有很多示例可用
There is nothing out of the box that will do this but it can be accomplished easily with some javascript, for which there are many examples available


这篇关于在asp.net中使用转发器中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆