zoukankan      html  css  js  c++  java
  • webform单选、复选

    单选框:RadioButton
    属性:GroupName:组名,如果要实现单选效果,每个单选按钮的组名必须一样
    看一下该按钮是否选中:RadioButton1.Checked;

    单选按钮列表:RadioButtonList
    属性:RepeatDirection:横向或纵向
    绑定数据:
    RadioButtonList1.DataSource = context.Nation;
    RadioButtonList1.DataTextField = "Name";
    RadioButtonList1.DataValueField = "Code";
    RadioButtonList1.DataBind();
    取选中项的值:
    RadioButtonList1.SelectedValue.ToString();
    设置哪一项被选中:
    RadioButtonList1.SelectedIndex = 2;

    复选框:CheckBox
    看一下该按钮是否选中:checkbox1.Checked;

    复选框列表:CheckBoxList
    属性RepeatDirection:横向或纵向
    绑定数据:
    CheckBoxList1.DataSource = context.Nation;
    CheckBoxList1.DataTextField = "Name";
    CheckBoxList1.DataValueField = "Code";
    CheckBoxList1.DataBind();
    取选中项的值:
    foreach (ListItem item in CheckBoxList1.Items)
    {
    if (item.Selected)
    {
    Label1.Text += item.Text;
    }
    }
    设置哪项选中:
    如果设置一项选中:SelectedIndex = 2;
    如果设置多项选中:foreach()

  • 相关阅读:
    二维hash(Uva 12886)
    C#中的线程(一)入门
    全国各地所有高校名单数据库 全国所有高校排名
    协议与代理
    表的约束条件
    na 斐波那契数列f(f(n))
    gcd题目
    Neighbor 隔壁
    hadoop
    Mybatis中实现mysql分页写法!!注意
  • 原文地址:https://www.cnblogs.com/wang-kaifeng/p/5051981.html
Copyright © 2011-2022 走看看