Just continue to nest the queries...
if (!string.IsNullOrEmpty(txtFullName.Text)
|| !string.IsNullOrEmpty(txtEmail.Text)
|| !string.IsNullOrEmpty(txtHandPhone.Text)
|| !string.IsNullOrEmpty(txtExtension.Text)
|| ddlDivision.SelectedItem.Value != "0" || ddlBranch.SelectedItem.Value != "0")
{
SPQuery
query = new SPQuery();
query.Query =
"<OrderBy>" +
"
<FieldRef Name='ID' />" +
"</OrderBy>" +
"<Where>" +
"<Or>" +
" <Contains><FieldRef Name='FullName'
/><Value Type='Text'>" +
txtFullName.Text + "</Value></Contains>" +
"<Or>" +
" <Contains><FieldRef Name='DID' /><Value
Type='Text'>" + txtExtension.Text + "</Value></Contains>" +
"<Or>" +
" <Contains><FieldRef Name='Handphone'
/><Value Type='Text'>" +
txtHandPhone.Text + "</Value></Contains>" +
"<Or>" +
" <Contains><FieldRef Name='Branch' /><Value
Type='Text'>" + ddlBranch.SelectedItem.Text + "</Value></Contains>" +
"<Or>" +
" <Contains><FieldRef Name='Division'
/><Value Type='Text'>" + ddlDivision.SelectedItem.Text
+ "</Value></Contains>" +
" <Contains><FieldRef Name='Email' /><Value
Type='Text'>" + txtEmail.Text + "</Value></Contains>" +
"</Or>" +
"</Or>" +
"</Or>" +
"</Or>" +
"</Or>" +
"</Where>";
}
-----------------AND Condition-------------
<And>
<Eq>... condition...</Eq>
<And>
<Eq>... condition...</Eq>
<And>
<Eq>... condition...</Eq>
<And>
<Eq>... condition...</Eq>
<Eq>... condition...</Eq>
</And>
</And>
</And>
</And>
No comments:
Post a Comment