protected void ListBox
_SelectedIndexChanged(object sender
EventArgs e)
{
thisListBoxItemsClear()
string s = select * from class where sid= + thisListBoxSelectedValue + ;
SqlConnection ccc = new SqlConnection()
cccConnectionString = ConfigurationManagerConnectionStrings[strcnn]ConnectionString;
SqlCommand cmm = new SqlCommand(s ccc)
cccOpen()//调用数据库
SqlDataReader myr;
myr = cmmExecuteReader()
while (myrRead())
{
thisListBoxItemsAdd(new ListItem(myr[classname]ToString() myr[id]ToString()))
}
}代码写在listbox的SelectedIndexChanged属性里面
然后autopostback为ture就可以上传到服务器
然后在里面写代码 获取listbox的选中项 从数据库获取数据 这时候就看着上班代码 就可以更新了