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

  • 相关阅读:
    存货核算中的加权平均
    System stored procedures
    javascript中replace与正则表达式
    AfxGetApp 解剖
    MFC中的文字输出
    函数指针的应用
    MFC消息处理与SDK消息处理
    在本地机器上获取root权限
    文件内容读取
    Linux下安装windows系统的方法
  • 原文地址:https://www.cnblogs.com/wang-kaifeng/p/5051981.html
Copyright © 2011-2022 走看看