0

我正在使用国家 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;

    }
4

1 回答 1

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();
    }
}
于 2012-08-24T18:55:45.143 回答