DropDownList二级联动,选择第一个DropDownList的时候,第二个DropDownList没反应
代码如下:
string sqlStr2 = "SELECT [NType_FatherId], [NType_Name], [NType_ID], [NType_ShopId] FROM NewsTypeInfo WHERE (NType_FatherId = 0) ORDER BY [NType_ID] desc";
DataAccess daa = new DataAccess();
daa.Open(DataFactory.DbType.DataBaseType.Sql);
DataSet dss = daa.GetDsSelectBySql(sqlStr2);
daa.Close();
this.DropDownList1.DataSource = dss;
this.DropDownList1.DataBind();
if (DropDownList2.SelectedValue != "")
{
string sqlStr = "select * from NewsTypeInfo where NType_FatherId=" + DropDownList1.SelectedValue + " order by NType_ID desc";
DataAccess da11 = new DataAccess();
da11.Open(DataFactory.DbType.DataBaseType.Sql);
DataSet ds11 = da11.GetDsSelectBySql(sqlStr);
da11.Close();
this.DropDownList1.DataSource = ds11;
this.DropDownList1.DataBind();
BandGVTypesSource();
}
else if (Session["NCSS_JUserID"] != null)
{
string sqlStr = "select * from NewsTypeInfo where News_TypeId in (select Ntype_ID from NewsTypeInfo where Ntype_shopID in (select Shop_ID from ShopDetail where Shop_JUId=" + Session["NCSS_JUserID"] + ")) order by News_id desc";
DataAccess da11 = new DataAccess();
da11.Open(DataFactory.DbType.DataBaseType.Sql);
DataSet ds11 = da11.GetDsSelectBySql(sqlStr);
da11.Close();
this.DropDownList1.DataSource = ds11;
this.DropDownList1.DataBind();
}