Friday, August 12, 2011

How to check for null with a CAML Query in OBJECT MODEL



                SPQuery qryReportLibrary = new SPQuery();
               // Check the value is null ??
                if (!string.IsNullOrEmpty(ddlMisson.SelectedValue))
                    qryReportLibrary.Query = string.Format(@"<Where>
                          <Eq>
                             <FieldRef Name='Misson' />
                             <Value Type='LookupMulti'>{0}</Value>
                          </Eq>
                       </Where>", ddlMisson.SelectedValue);
                else
                {
                    qryReportLibrary.Query = string.Format(@"<Where>
                        <IsNull>
                            <FieldRef Name='Mission'/>
                       </IsNull>
                       </Where>");
                }
               
                qryReportLibrary.Query = strQuery;