Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Sharepoint
<pre> public void QueryhMethodebyid()
        {
 
            SPSite osite = SPContext.Current.Site;
            SPWeb Oweb = osite.OpenWeb();
            Oweb.AllowUnsafeUpdates = true;
            SPList olist = Oweb.Lists["Documents"];
            SPQuery query = new SPQuery();
            query.ViewAttributes = "Scope=\"Recursive\"";
            query.ViewFieldsOnly = true;
            query.RowLimit = 5;
 
            query.ViewFields = string.Concat("<FieldRef Name='ID' />",
                "<FieldRef Name='Costumers' />",
                "<FieldRef Name='Costumers_x003a__x0020_YomiFullName' />",
                "<FieldRef Name='ContentType' />",
                "<FieldRef Name='Technician' />",
                "<FieldRef Name='Document_Description' />",
                "<FieldRef Name='Scandate' />",
                "<FieldRef Name='Management' />",
                "<FieldRef Name='Created' />",
                "<FieldRef Name='URL' />");
 

            //  query.Query = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + txtId.Text + "</Value></Eq></Where>";
            //    query.Query =   @"<Where><Or><Eq><FieldRef Name='ID' /><Value Type='Counter'>"+ txtId.Text   +"</Value></Eq><Or><Contains><FieldRef Name='Document_Description' /><Value Type='Text'>"+txtdescription.Text    +"</Value></Contains><Or><Eq><FieldRef Name='Technician' /><Value Type='Choice'>"+DropDTech.SelectedValue+ "</Value></Eq><Or><Eq><FieldRef Name='Department' /><Value Type='Choice'>"+DropDownDepartment.SelectedValue +"</Value></Eq><Or><Eq><FieldRef Name='ContentTyp' /><Value Type='Computed'>"+ DropdownContentype.SelectedValue+"</Value></Eq><Or><Eq><FieldRef Name='Scandate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>"+ Scandates.SelectedDate+"</Value></Eq><Or><Eq><FieldRef Name='Costumers' /><Value Type='Text'>"+ DROPCost.SelectedValue    +"</Value></Eq><Or><Eq><FieldRef Name='Costumers_x003a__x0020_YomiFullName' /><Value Type='Note'>"+ DropDownGrid.SelectedValue   +"</Value></Eq><Or><Eq><FieldRef Name='URL' /><Value Type='URL'>"+UrlDocumentpath+"</Value></Eq><And><Geq><FieldRef Name='Created' /><Value IncludeTimeValue='TRUE' Type='DateTime'>"+DatePickerStart.SelectedDate+ "</Value></Geq><Leq><FieldRef Name='Created' /><Value IncludeTimeValue='TRUE' Type='DateTime'>"+ DatepickerEnd.SelectedDate   +"</Value></Leq></And></Or></Or></Or></Or></Or></Or></Or></Or></Or></Where>";          

            query.Query = @"<Where><Or><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + txtId.Text + "</Value></Eq><Or><Eq><FieldRef Name='Technician' /><Value Type='Choice'>" + DropDTech.SelectedValue + "</Value></Eq><Or><Eq><FieldRef Name='Department' /><Value Type='Choice'>" + DropDownDepartment.SelectedValue + "</Value></Eq><Or><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>" + DropdownContentype.SelectedValue + "</Value></Eq><Or><Eq><FieldRef Name='Scandate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>" + Scandates.SelectedDate + "     </Value></Eq><Or><Eq><FieldRef Name='Costumers' /><Value Type='Text'>" + DROPCost.SelectedValue + "</Value></Eq><Or><Eq><FieldRef Name='Costumers_x003a__x0020_YomiFullName' /><Value Type='Note'>" + DropDownGrid.SelectedValue + " </Value></Eq><Or><Eq><FieldRef Name='URL' /><Value Type='URL'>" + UrlDocumentpath + "</Value></Eq><Or><Eq><FieldRef Name='Management' /><Value Type='Choice'>" + DropDManagement.SelectedValue + "</Value></Eq><And><Geq><FieldRef Name='Created' /><Value IncludeTimeValue='TRUE' Type='DateTime'>" + DatepickerEnd.SelectedDate + "</Value></Geq><Leq><FieldRef Name='Created' /><Value IncludeTimeValue='TRUE' Type='DateTime'>" + DatePickerStart.SelectedDate + "</Value></Leq></And></Or></Or></Or></Or></Or></Or></Or></Or></Or></Where>";
 

 

 
            string resulbyid = "";
            string DocuNaam = "DocuLink";
            string resultscandate = "";
            string resultscostumers = "";
            string resultdescription = "";
            string resulttechician = "";
            string resultcontactbycostumer = "";
            string resultcontenttype = "";
            string resultcreatedate = "";
            string resultlinkurl = "";
            string resultDepartment = "";
            string idl = "ID:";
            string scandatel = "scandate:";
            string costumersl = "costumers:";
            string contactl = "contact:";
            string descriptl = "description:";
            string techl = "technican:";
            string departl = "Department";
            string contentTypel = "contenttype:";
            string CreatedDatel = "Created:";
            string linkl = "URL:";
 
            SPListItemCollection collListItems = olist.GetItems(query);
 
            int i = 0;
            foreach (SPListItem oListItem in collListItems)
            {
                          
                    resulbyid += SPEncode.HtmlEncode(oListItem["ID"].ToString());
                 
                    resultcontactbycostumer += oListItem["Costumers_x003a__x0020_YomiFullName"];
 
                    resultdescription += oListItem["Document_Description"];
 
                    resultscandate += oListItem["Scandate"];
 
                    resulttechician += oListItem["Technician"];
 
                    resultcontenttype += oListItem["ContentType"];
 
                    resultcreatedate += oListItem["Created"];
 
                    resultlinkurl += oListItem.File.Url;
 
                                 
                    i++;
 
                    
                
            }
 

           
 

 

            txtresultid.Text = idl + " " + resulbyid + "<BR>" + '\n'
                  + scandatel + " " + resultscandate + "<BR>" + '\n'
               + contactl + " " + resultcontactbycostumer + "<BR>" + '\n' +
                costumersl + " " + resultscostumers + "<BR>" + '\n'
                + descriptl + " " + resultdescription + "<BR>" + '\n'
                 + departl + " " + resultDepartment + "<BR>" + '\n'
                 + techl + " " + resulttechician + "<BR>" + '\n'
                 + contentTypel + " " + resultcontenttype + "<BR>"
                + linkl + "<A href=" + UrlDocumentpath + resultlinkurl + ">" + DocuNaam + "</A>" + "<BR>" + '\n'
                 + CreatedDatel + " " + resultcreatedate + "<BR>";
 

 

 
            DataTable items = olist.GetItems(query).GetDataTable();
 
            GridVIewSearch.DataSource = items;
            GridVIewSearch.DataBind();
 

        }
Posted 21-May-12 3:39am
Comments
Mark Nischalke at 21-May-12 8:42am
   
Rather than dumping code it would be better to explain your situation and ask an actual question.
B Birajdar at 21-May-12 10:08am
   
So whats your problem ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 645
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581


Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 21 May 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100