Asp.net ListBox填充探针 [英] Asp.net ListBox Filling Probelm
本文介绍了Asp.net ListBox填充探针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void lstActivity_SelectedIndexChanged(object sender, EventArgs e)
{
listview();
}
public void listview()
{
try
{
string company = lstActivity.SelectedItem.Text;
reader = obj.SelCommand("Select activity from tbl_activity where company_id=(select id from tbl_company where company_name='" + company + "') and department=(select dept from tbl_login where username='" + lbluser.Text + "')");
lstCompany.Items.Clear();
while (reader.Read())
{
lstCompany.Items.Add(reader["activity"].ToString());
}
reader.Close();
}
catch (Exception ex)
{
Response.Write("Error in page :" + ex.Message);
}
}
上面是代码.我用数据库中的值填充了一个列表框.
我有两个列表框-第一个填充页面加载,第二个填充第一个列表框的selectedindexchanged
事件.
填充selectedIndexchanged
事件的列表框未加载.但是,如果我将它放在按钮单击事件中,它将起作用.
请帮助我用selectedindexchanged
event
Above is the code. I filled a listbox with values from database.
I have two listboxes - first one is filling in the pageload and the second is filling on the selectedindexchanged
event of first listbox.
The listbox filling in the selectedIndexchanged
event is not loading. But, if I put it in a button click event, it works.
Kindly help me to fill it with selectedindexchanged
event
推荐答案
设置autopostback property = true
Set autopostback property=true
这篇关于Asp.net ListBox填充探针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文