遍历控件啊foreach (Control ct in form1.Controls)
        {
            if (ct.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
            {                CheckBox cb = (CheckBox)ct;
                cb.Checked = true ;            }
        }

解决方案 »

  1.   

    也可以直接在前台用Jquery获取选中复选框。
    $("input:checkbox:checked")...
      

  2.   


    如果我想给第一个人投票,我应该如何让程序自动选取第一个人的复选框呢?还有你这里的foreach (Control ct in form1.Controls),我应该改成foreach (Control ct in webBrowser1.Controls)对吧
      

  3.   

    google webbrowser控件 投票程序。
      

  4.   

    关注, 我也有这样类似的疑问。
    http://www.51zxw.net/study.asp?vip=8963801
    推荐爱学习的人看
      

  5.   

    数据绑定后,设置选择状态为true不就行吗?
      

  6.   

    单选复选框
    <asp:CheckBoxList DataTextField="choice" DataValueField="id" id="cbChoice" runat="server" Visible="false"></asp:CheckBoxList>
    提交按钮
    <asp:ImageButton id="ibtnOk" runat="server" ImageUrl="images/button1.gif"></asp:ImageButton>
      

  7.   

    只选一个人,为什么不用Radio单选呢?
      

  8.   

    //设置CheckBox控件
    <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" Font-Size="9pt" OnCheckedChanged="CheckBox2_CheckedChanged"
                                        Text="全选" Width="54px" />
    //设置处理按钮
    <asp:Button ID="btnDelte" runat="server" OnClick="Button2_Click" Text="批量删除" Width="81px" />
    //处理事件功能
     protected void Button2_Click(object sender, EventArgs e)
        {
            //ST_myConn.Open();
            for (int i = 0; i <= ClassList.Rows.Count - 1; i++)
            {
                CheckBox cbox = (CheckBox)ClassList.Rows[i].FindControl("CheckBox1");
                if (cbox.Checked == true)//CodeGo.net/
                {
                    string sqlstr = "delete from ST_class where ST_c_id='" + ClassList.DataKeys[i].Value + "'";
                    My_sqldata.ExceSQL(sqlstr);
                    Response.Write("<script language=javascript>alert('批量删除成功!');location='BlogType.aspx'</script>");
                }
            } 
        }