当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net利用listbox查看内部列

asp.net利用listbox查看内部列

2018年12月07日  | 移动技术网IT编程  | 我要评论

特异功能猩求人,cctv6中国通史,哈酷资源网

 protected void listbox1_selectedindexchanged(object sender, eventargs e)
    {
 this.listbox2.items.clear();
        string s = "select * from class where sid='" + this.listbox1.selectedvalue + "'";
        sqlconnection ccc = new sqlconnection();
        ccc.connectionstring = configurationmanager.connectionstrings["strcnn"].connectionstring;
        sqlcommand cmm = new sqlcommand(s, ccc);
        ccc.open();//调用
        sqldatareader myr;
        myr = cmm.executereader();
        while (myr.read())
        {
            this.listbox2.items.add(new listitem(myr["classname"].tostring(), myr["id"].tostring()));
        }

}代码写在listbox1的selectedindexchanged属性里面

然后autopostback为ture就可以上传到服务器 

然后在里面写代码    获取listbox1的选中项  从数据库获取数据 这时候就看着上班代码 就可以更新了

 

摘自 liuningshiwoa的专栏

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网