• 用Hashtable表绑定数据到下拉框、复选框列表、单选框列表、ListBox


      //前台
    <asp:RadioButtonList ID="rb1" runat="server">
    </asp:RadioButtonList>
    <asp:DropDownList ID="ddlshe" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlshe_SelectedIndexChanged">
    </asp:DropDownList>
    <br />
    <asp:ListBox ID="lba" runat="server"></asp:ListBox>
    <br />
    <asp:CheckBoxList ID="cbl" runat="server">
    </asp:CheckBoxList>
    //后台:
    SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
    builder.DataSource = ".";
    builder.InitialCatalog = "MyDatas";
    builder.IntegratedSecurity = true;
    using (SqlConnection con = new SqlConnection(builder.ConnectionString))
    {
    con.Open();
    SqlCommand cmd = new SqlCommand("select id,title from tb_forums", con);
    using (SqlDataReader reader = cmd.ExecuteReader())
    {
    Hashtable ht = new Hashtable();
    while (reader.Read())
    {
    ht.Add(reader["title"].ToString(), reader["title"].ToString());
    }
    ddlshe.Items.Clear();
    lba.Items.Add("请选择");//ListBox
    ddlshe.Items.Add("请选择"); //下拉框列表
    rb1.Items.Add("请选择"); //单选框列表
    cbl.Items.Add("请选择");//复选框列表
    foreach (DictionaryEntry de in ht)
    {
    ListItem item = new ListItem(de.Value.ToString(), de.Key.ToString());
    ddlshe.Items.Add(item);
    lba.Items.Add(item);
    cbl.Items.Add(item);
    rb1.Items.Add(item);
    }
    }
    }
    }
  • 相关阅读:
    M1(全称:NXP Mifare1系列)卡存取控制位的编码规则
    iBluetooth用户协议
    PN532教程
    电梯卡系统辨别方法
    RFID安全十大问题与威胁
    iBluetooth隐私政策
    Proxmark:克隆IC卡
    React.createElement
    react的table组件
    https://cssgradient.io/
  • 原文地址:https://www.cnblogs.com/Stephenchao/p/2429669.html
Copyright © 2020-2023  润新知