当前位置:编程学习 > C#/ASP.NET >>

RadioButtonList1

怎样判断RadioButtonList中的项是否选中 --------------------编程问答-------------------- 通过FindControl(单选按钮ID),找到控件后,判断checked属性 --------------------编程问答-------------------- this.RadioButton1.Checked = true  选中 --------------------编程问答--------------------         for (int i = 0; i < RadioButtonList1.Items.Count; i++)
            if (RadioButtonList1.Items[i].Selected)
                Response.Write("你选中了第" + (i+1).ToString() + "项"); --------------------编程问答-------------------- 用for循环,代码如下:

for (int i = 0; i < RadioButtonList1.Items.Count; i++) 
{
   if (RadioButtonList1.Items[i].Selected) 
   {
      Response.Write("你选中了第" + (i+1).ToString() + "项");
   }
}
--------------------编程问答--------------------

 if (RadioButtonList1.SelectedIndex != -1)
        {
            Response.Write(RadioButtonList1.SelectedItem.Text);
        }
        else
        {
            Response.Write("请选择");
        }

--------------------编程问答--------------------

 if (RadioButtonList1.SelectedIndex != -1)
        {
            Response.Write(RadioButtonList1.SelectedItem.Text);
        }
        else
        {
            Response.Write("请选择");
        }

补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,