zoukankan      html  css  js  c++  java
  • RadioButtonList

    1.用法

    <asp:RadioButtonList ID="rblIsLock" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Selected="True" Value="0">启用 </asp:ListItem>
                            <asp:ListItem Value="1">禁用 </asp:ListItem>
                        </asp:RadioButtonList><label>*禁用的用户将无法登录</label>

    2.RadioButtonList控件里的每项asp:ListItem添加单独的ToolTip也就是鼠标悬停的提示信息

    protected void Page_Load(object sender, EventArgs e)
        {
            RadioButtonList1.Items[0].Attributes.Add("title", "111");
            RadioButtonList1.Items[1].Attributes.Add("title", "111");
        }

    3.使用复杂绑定完成 CheckBoxList 和 RadioButtonList 控件的绑定

    View Code
    前台:
    
    <body>
    
        <form id="form1" runat="server">
        <div>
            <asp:RadioButtonList ID="RadioButtonList1" runat="server">
            </asp:RadioButtonList>
            <br />
            <br />
            <asp:CheckBoxList ID="CheckBoxList1" runat="server">
            </asp:CheckBoxList>
        </div>
        </form>
    
    </body>
    
    
    后台:
    
     protected void Page_Load(object sender, EventArgs e)
            {
                string sql = "select * from province";
                DataTable dt = SQLHelper.ExecuteDataTable(sql);
                this.RadioButtonList1.DataSource = dt;
                this.RadioButtonList1.DataTextField = "Provinces";
                this.RadioButtonList1.DataValueField = "PId";
                this.RadioButtonList1.DataBind();
    
                this.CheckBoxList1.DataSource = dt;
                this.CheckBoxList1.DataTextField = "Provinces";
                this.CheckBoxList1.DataValueField = "PId";
                this.CheckBoxList1.DataBind();
            }
    
    
    SQLHelper类:
    public static DataTable ExecuteDataTable(string sql, params SqlParameter[] pms)
        {
            DataTable dt = new DataTable();
            SqlDataAdapter adapter = new SqlDataAdapter(sql,connStr);
            if (pms != null)
            {
                adapter.SelectCommand.Parameters.AddRange(pms);
            }
            adapter.Fill(dt);
            return dt;
        }

    4.当选项被选中时,更改选中选项的前景色

    View Code
     <asp:RadioButtonList ID="rblIsLock" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rblIsLock_SelectedIndexChanged" 
     RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Selected="True" Value="0">启用 </asp:ListItem>
                            <asp:ListItem Value="1">禁用 </asp:ListItem>
                        </asp:RadioButtonList><label>*禁用的用户将无法登录</label>
    
    后台:
     protected void rblIsLock_SelectedIndexChanged(object sender, EventArgs e)
        {
            var rbl = sender as RadioButtonList;
            HighliehgSelectedItem(rbl);
        }
    
        private void HighliehgSelectedItem(RadioButtonList rbl)
        {
            foreach (ListItem li in rbl.Items)
            {
                if (li.Selected)
                {
                    li.Attributes.Add("style", "color: red;");
                }
            }
        }
  • 相关阅读:
    atitit.按钮光标滑过高亮切换以及其他动态效果的实现css html js attilax总结
    atitit. 文件上传带进度条 atiUP 设计 java c# php
    atitit.新增编辑功能 跟orm的实现 attilax p31
    atitit. java jsoup html table的读取解析 总结
    atitit.设计文档操作日志的实现
    atitit.资源释放机制attilax总结
    (转)Android的消息机制,用Android线程间通信的Message机制,Android中Handler的使用方法——在子线程中更新界面,handler机制
    (转)Android笔记handler机制
    (转)数据存储
    (转)android连网详解
  • 原文地址:https://www.cnblogs.com/LifeKingcn/p/2825120.html
Copyright © 2011-2022 走看看