Well, you're not checking null references in your code... I have done some similar stuff (but the code is buried deep), but look at this post by Karoline
http://karolikl.blogspot.com/2009/09/using-query-system-in-episerver.html
Maybe that can give you some help
Since the clubs are retrieved from a dropdownlist, which is previously filled from a club-query, I see no points where a null-reference could occur. Where should I check for null-recerences then?
crit.Club.ID.Includes.Values.Add( Convert.ToInt32( item.Value ) ); - item.Value, I think Convert will fail if there is no data in item.Value. Haven't tested the code, but it could happen, maybe =)
But item.Value has a value. The error also occurs on the execution of the query, not on converting the value of the item.
I'm trying to get a list of all users who are members of some specified of clubs, but I keep getting a null-reference exception when I execute the query.
The code I'm using:
------------------------------------------------------------------------------------------------------------------------------
MembershipCriterion crit = newMembershipCriterion();
crit.Club = newClubCriterion();
crit.Club.ID = newIntegerCriterion();
crit.Club.ID.Includes = newIntegerInCriterion();
foreach (ListItem item in clubs.Items.OfType<ListItem>().Where( t => t.Selected ).ToList())
{
crit.Club.ID.Includes.Values.Add( Convert.ToInt32( item.Value ) );
}
query.Criteria.Add( "Clubs", crit );
------------------------------------------------------------------------------------------------------------------------------
Any idea what could be wrong with this code?