我使用国家/地区DDL中的文本填写州DDL
foreach (var VARIABLE in ProfileMasterDAL.bindcountry())
{
if (VARIABLE.ToString().Contains(DropDownList1.SelectedItem.Text))
{
var query = from row in ProfileMasterDAL.bindstate().ToString()
where
ProfileMasterDAL.bindstate().ToString().Contains(DropDownList1.SelectedItem.Text)
select row;
DropDownList2.DataSource = query;
DropDownList2.DataBind();
}
}
但是在查询时我得到的枚举没有结果,状态DDL是空的。
public static IEnumerable bindstate()
{
var states = from b in getdata().Descendants("state").SelectMany(state => state.Elements("text"))
orderby (string) b
select (string) b;
return states;
}
答案 0 :(得分:0)
好的,基于评论和对问题的更新,我认为这就是你想要的:
foreach (var VARIABLE in ProfileMasterDAL.bindcountry())
{
if (VARIABLE.ToString().Contains(DropDownList1.SelectedItem.Text))
{
var query = from row in ProfileMasterDAL.bindstate()
where row.Contains(DropDownList1.SelectedItem.Text)
select row;
DropDownList2.DataSource = query;
DropDownList2.DataBind();
}
}