asp:ListBox三级联动问题.
问题:第三个ListBox无法联动.
代码:
private DataAccess da;
private DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
lbx1Bind();
}
}
protected void lbx1_SelectedIndexChanged(object sender, EventArgs e)
{
lbx2Bind();
}
protected void lbx2_SelectedIndexChanged(object sender, EventArgs e)
{
lbx3Bind();
}
private void lbx1Bind()
{
da = new DataAccess();
dt = new DataTable();
dt = da.GetDt( "select * from Class where S_ID=0 ");
lbx1.DataTextField = "Name ";
lbx1.DataValueField = "C_ID ";
lbx1.DataSource = dt;
lbx1.DataBind();
}
private void lbx2Bind()
{
da = new DataAccess();
dt = new DataTable();
dt = da.GetDt( "select * from Class where S_ID= ' " + lbx1.SelectedValue + " ' ");
lbx2.DataTextField = "Name ";
lbx2.DataValueField = "C_ID ";
lbx2.DataSource = dt;
lbx2.DataBind();
}
private void lbx3Bind()
{
da = new DataAccess();
dt = new DataTable();
dt = da.GetDt( "select * from Class where S_ID= ' " + lbx2.SelectedValue + " ' ");