Saturday, November 22, 2008

How to find one list item from the Listitems

SPDocumentLibrary ContractsLib;
SPListItemCollection contractsItems;
ContractsLib = (SPDocumentLibrary)myweb.Lists["Contracts"];
SPListItem clistitem;
String EmployeeNumber=Request.QueryString["EmployeeNumber "] != null)
{
SPListItemCollection contractsItems;
String strContractNumber = Request.QueryString["ContractNumber"];
ENumberQuery = new SPQuery();
// Belowed one line of code will help you to loop through all the items;
ENumberQuery.ViewAttributes = "Scope=\"Recursive\"";
ENumberQuery.Query = "" +
" + "\"ID\"" + " />" +
"" +"" +"" +" + "\" EmployeeNumber \"" + " />" +
" + "\"Text\"" + ">" + strContractNumber + "" +
"" +
"";
contractsItems = ContractsLib.GetItems(ENumberQuery);

clistitem = contractsItems[0];


No comments: