本帖最后由 tianlebest 于 2010-06-17 11:29:41 编辑

解决方案 »

  1.   

    都可以实现, 主要在于你自己的想法, HTML 的话 可以 添加一个 隐藏域,然后用JS 实现 获得选中的多选按钮的值,赋给隐藏域, 服务器控件 直接循环获得每一行的多选按钮 判断是否选中,然后 获得选中的多选按钮的值,
    有没有选中判断 累加的值是否为空 
      

  2.   

    建议用html控件不过写JS费点劲,不过这样能减少服务器开销
      

  3.   

    HTML控件最好了,JS写起来也简单!
      

  4.   

    加上一个for(比如:for(i=0,i<=vector.size(),i++))循环,定义一个i 变量,利用索引的方式检索你需要的数据!
      

  5.   

    这跟服务器控件还是html控件没有直接的关系,
    但是这样的操作还是应该放到客户端来验证,毕竟比较快,
    如果要求比较严格的话,再服务器端再做一次判断也是可以的。
      

  6.   

    给你贴点代码吧,看代码最容易理解了:
    前台代码:
       <asp:CheckBox ID="infoCheck" runat="Server" Text='<%#DataBinder.Eval(Container.DataItem, "ID")%>' />后台代码:
     for (int i = 0; i < CompanyRep.Items.Count; i++)
            {
                CheckBox isChecked = (CheckBox)CompanyRep.Items[i].FindControl("infoCheck");
                if (isChecked.Checked == true)
                {
                    int ID = Convert.ToInt32(isChecked.Text);
                    hycompanybll.delComByCompanyid(ID);
                }
            }其中CompanyRep是repeater控件,你可以在这里面做判断
      

  7.   

      //全选
            protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
            {
                if (((CheckBox)sender).Checked)
                {
                    for (int rowIndex = 0; rowIndex < gridShowClientInfos.Rows.Count; rowIndex++)
                    {
                        ((CheckBox)gridShowClientInfos.Rows[rowIndex].FindControl("checkSelected")).Checked = true;
                    }
                }
                else
                {
                    for (int rowIndex = 0; rowIndex < gridShowClientInfos.Rows.Count; rowIndex++)
                    {
                        ((CheckBox)gridShowClientInfos.Rows[rowIndex].FindControl("checkSelected")).Checked = false;
                    }
                }
            }
            //反选
            protected void checkedNoSelected_CheckedChanged(object sender, EventArgs e)
            {
                for (int rowIndex = 0; rowIndex < gridShowClientInfos.Rows.Count; rowIndex++)
                {
                    if ((((CheckBox)gridShowClientInfos.Rows[rowIndex].FindControl("checkSelected")).Checked == true))
                    {
                        ((CheckBox)gridShowClientInfos.Rows[rowIndex].FindControl("checkSelected")).Checked = false;
                    }
                    else
                    {
                        ((CheckBox)gridShowClientInfos.Rows[rowIndex].FindControl("checkSelected")).Checked = true;
                    }
                }
            }
      

  8.   

      if (((CheckBox)sender).Checked)
                {
                   //用户选择了
                 }
    else
               {
                    //用户没有选择            }
      

  9.   

    以下代码测试通过
    for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    string xxyy;
                    CheckBox xxx = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
                    xxyy = ((HyperLink)GridView1.Rows[i].FindControl("hk2")).Text;
                    if (xxx.Checked)
                    {
                        cs1.Text += xxyy + ",";
                    }
                }
                if (cs1.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "ToolTip", "alert('请选择方能比较!')", true);
                }
                else
                {
                   //执行跳转等操作
                    cs1.Text = "";
                }
      

  10.   

    如果用HTML控件的话,点执行的话肯定是先判断有没有选择的(这个已实现),但问题是怎么提交到服务器端去执行相关“删除。审核”等的操作啊
      

  11.   

    用得着吗?。。如果这全选反选都要去服务器交付,那么开销也太大了吧!用js就很简单的完成
    思路:
    1:var contraints=document.getElementById("你这个gridView的id号")
    2: var checkboxs=contraints.getElementsByTagName("Checkbox");
    3:for(var i=0;i<checkboxs.length;i++){
        //这里面就判断checked选中或是没有选中的操作
      }
      

  12.   

    用javascript就可以!能在客户端解决的就在客户端解决!