我填充狀態DDL使用國家DDL填充狀態DDL使用國家DDL在LINQ
public static IEnumerable bindcountry()
{
var countries = from c in getdata().Descendants(("country"))
orderby (string)c.Element("name")
select (string)c.Element("name");
return countries;
}
public List<string> GetStatesByCountry(string CountryName)
{
var query = from user in getdata().Descendants("country")
where user.Element("name").Value == CountryName
from t in user.Descendants("text")
select t.Value;
return query.ToList();
}
foreach (var VARIABLE in ProfileMasterDAL.bindcountry())
{
if (VARIABLE.ToString().Contains(DropDownList1.SelectedItem.Text))
{
var query = from row in ProfileMasterDAL.bindcountry()
where row.(ProfileMasterDAL.GetStatesByCountrys(DropDownList1.SelectedItem.Text))
select row;
DropDownList2.DataSource = query;
DropDownList2.DataBind();
}
}
的問題是我無法定義WHERE子句和等於我在這裏得到一個錯誤:
Could not find an implementation of the query pattern for source type 'System.Collections.IEnumerable'. 'Where' not found. Consider explicitly specifying the type of the range variable 'row'.
但在此代碼之前像DropDownList1.SelectedValue = Session [「country」]。ToString();而國家的DDL值不會改變到另一個國家,我該如何改變它? –