例如:1,2,3;选中2了,怎么表示,刚刚学习,纯新的手!

解决方案 »

  1.   

    <select>
      <option>Volvo</option>
      <option selected="selected">Saab</option>
      <option>Mercedes</option>
      <option>Audi</option>
    </select> 
      

  2.   

    贴错了
    设置checked属性。<input type="radio" name="fruit" value = "Apple">苹果<br>
    <input type="radio" name="fruit" value = "Orange" checked=true>桔子<br>
    <input type="radio" name="fruit" value = "Mango">芒果<br>
      

  3.   

    贴出你的代码,你用的是html控件还是服务器控件?
      

  4.   

    if (RadioButton1.Checked = true)
            { 
                authorityname = "管理员";
                authority = "1";
            }
            if (RadioButton2.Checked = true)
            {
                authorityname = "专家";
                authority = "2";
            }
            if (RadioButton3.Checked = true)
            {
                authorityname = "用户";
                authority = "3";
            }
    此时,这三个单选按钮都可以选,后来用单选按钮组有三个单选按钮,如何表示其中的一项?
      

  5.   

    因为单选按钮控件RadioButton是互斥的,只要将多个放入容器控件例如GroupBox中,代码使用多重分支即可,另外代码中的RadioButton1.Checked本身就是布尔类型不用判断了,(比较应为==)
      if (RadioButton1.Checked)
       {  
         authorityname = "管理员";
         authority = "1";
       }
       else if (RadioButton2.Checked)
       {
         authorityname = "专家";
         authority = "2";
       }
       else (RadioButton3.Checked)
       {
         authorityname = "用户";
         authority = "3";
       }
      

  6.   

    用RadioButtonList<asp:RadioButtonList ID="RadioButtonList1" runat="server">
    <asp:ListItem Text="管理员" Value="1"></asp:ListItem>
    <asp:ListItem Text="专家" Value="1"></asp:ListItem>
    </asp:RadioButtonList>在后台使用this.RadioButtonList1.SelectedValue获取选中的值