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()

  • 相关阅读:
    nsq 启动流程讲解
    nsq 初识
    【资料】http包接口和结构体
    http包详解 2
    http包详解 1
    openstack多节点部署运维
    一款简单实用的串口通讯框架(SerialIo)
    ~MySQL Perfect~
    linux创建用户设置密码
    linux安装tomcat且配置环境变量
  • 原文地址:https://www.cnblogs.com/wang-kaifeng/p/5051981.html
Copyright © 2011-2022 走看看