I was retrieving data from sharepoint list. When my query was less that time no issues to display the data. But more than 300 or conditions invloved in that query exception is coming "value does not fall within the expected range"
SPList olistLegal = oWeb.Lists.TryGetList("TestList");
SPQuery LEoquery = new SPQuery();
LEoquery.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + Legalentityname + "</Value></Eq></Where>";
// SPListItemCollection oItemLegalentitycoll = olistLegal.GetItems(LEoquery);
foreach (SPListItem oItemLegalentitycoll in olistLegal.GetItems(LEoquery))
{
string contractid = Convert.ToString(oItemLegalentitycoll["ContractID"]);
if (string.IsNullOrEmpty(LegalEntityquery) == true)
{
LegalEntityquery = "<Eq><FieldRef Name='ContractID' /><Value Type='Text'>" + contractid + "</Value></Eq>";
}
else
{
LegalEntityquery = "<Or>" + LegalEntityquery + "<Eq><FieldRef Name='ContractID' /><Value Type='Text'>" + contractid + "</Value></Eq></Or>";
}
}
i was receiving this error in my webpart.