Access to a List
- From: linuxterrorist@xxxxxxxxx
- Date: 2 Aug 2006 05:44:33 -0700
Hello all,
I would like to list all items in a list. I have tested every method
and already no result.
SPWeb site = SPControl.GetContextWeb(Context);
SPList list = site.Lists["KM"];
SPQuery query = new SPQuery();
query.Query = "<Query><OrderBy><FieldRef Name='Title'
/></OrderBy></Query>";
SPListItemCollection listItems = list.GetItems(query);
foreach (SPListItem listItem in listItems)
{
//this.Label1.Text +=
SPEncode.HtmlEncode(listItem["ows_Title"].ToString());
}
With this code I have a NullException here :
SPList list = site.Lists["KM"];
but my list called KM exists. I don't understand. :|
When I use this code :
sharepoint.SiteData srvSiteData = new sharepoint.SiteData();
srvSiteData.Credentials =
System.Net.CredentialCache.DefaultCredentials;
string items =
srvSiteData.GetListItems("{B17796BC-0493-4B50-A268-391CE4BD821D}",
"<Where><Eq><FieldRef Name=\"Title\" /><Value
Type=\"Text\">Test</Value></Eq></Where>", "<FieldRef Name=\"Title\"
/><FieldRef Name=\"Client\" />", 500);
this.Label1.Text += items;
I have no result.
I hope that you could help me.
.
- Prev by Date: Re: Small farm vs Medium Farm
- Next by Date: Re: Impersonation problem in Sharepoint 2007
- Previous by thread: Re: Small farm vs Medium Farm
- Next by thread: Re: SharePoint Search - Wildcard and Scope
- Index(es):
Relevant Pages
|