我在camlex查询中遇到问题:我在2个下拉列表中列出了第二个列表中的查找。 当我在第一个下拉列表中选择一个项目时,我希望过滤第二个下拉列表。
第一个下拉列表:
DropDownList JobsList = new DropDownList();
JobsList.SelectedIndexChanged +=
new EventHandler(JobsList_SelectedIndexChanged);
protected void JobsList_SelectedIndexChanged(object sender, EventArgs e)
{
SPList jobs = SPContext.Current.Web.Lists["Jobs"];
string filter = string.Empty;
if (this.JobSelector.SelectedItem != null)
{
filter = this.JobSelector.SelectedItem.Text;
}
SPQuery query = new SPQuery
{
Query = Camlex.Query().Where(x => (((string)x["Jobs"]).Contains(filter))).ToString()
};
SPListItemCollection items = jobs.GetItems(query);
}
我在第二个下拉列表中遇到问题:
using (SPWeb clientWeb = clientSite.RootWeb)
{
string filter = string.Empty;
if(this.JobSelector.SelectedItem != null)
{
filter = this.JobSelector.SelectedItem.Text;
}
SPList subTypeList = clientWeb.Lists["SubTypes"];
SPQuery query = new SPQuery();
query.Query = Camlex.Query().Where(x => (((string)x["Jobs"]).Contains(filter))).ToString();
foreach (SPListItem subtype in subTypeList.GetItems(query))
{
this.subTypeSelectorID.Items.Add(new ListItem(subtype.Title, subtype.ID.ToString()));
}
}
我不明白为什么查询不好:
Query = Camlex.Query().Where(x => (((string)x["Jobs"]).Contains(filter))).ToString()
我尝试了另一种方法,但没有成功
<ViewFields>
<FieldRef Name='Title' />
<FieldRef Name='Jobs' />
</ViewFields>
<Where>
<Eq>
<FieldRef Name='Jobs' />
<Value Type='Lookup'>Authorizations</Value>
</Eq>
</Where>
有什么想法吗?
谢谢,