有一列的checkbox选项,但是只能选其中一行,如果要复选的话会提示不能多选。这个问题怎么解决啊~~最好能发放下代码。。

解决方案 »

  1.   

    晕。既然只能选择一个。那就用opiont
    <asp:TemplateField HeaderText="单选" FooterText="单选"> 
                        <ItemTemplate> 
                        <input type="radio" id="RadioName" name="RadioName" value='<%# Eval("id")%>' /> 
                        </ItemTemplate> 
                        </asp:TemplateField> 
      

  2.   

    后台获取值就用Request.Form.Get("RadioName");
      

  3.   

    在它的CheckChanged事件中写:foreach(GridViewRow gvr in GridView1.Rows)
    {
        CheckBox cb = gvr.FindControl("CheckBox1") as CheckBox;
        if(cb!=null && cb.Checked)
        {
             Response.Write("<script>alert('不能多选');</script>");
             return;
        }
    }
      

  4.   

    ojlovecd的这段代码应该放在哪里啊~~我直接放到page_load里面不行呢?~~
      

  5.   

    不是说了在CheckBox的CheckChanged事件中嘛,还有别忘了把CheckBox的AutoPostBack设为true