<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(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)