我填補了國家DDL使用文本在全國DDLLinq中
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;
}
你設置'DataSource'一個'foreach'內,這意味着你*可能會*設置多次,這不是一個好方法。另外,您正在查看該州是否包含國名?尷尬了。最後,當你調試它時,你有沒有進入'如果'的內部? –
你爲什麼試圖從字符串中選擇一些東西?這最終是針對'char []'的查詢,當然這不是你想要的? – CodingGorilla
我正在尋找包含州名的國家。是的,我已經進入瞭如果條件和即時通訊有問題的查詢。 –