Isaac
asked on
.NET CSOM
1) I created the below windows form and .NET Managed client object code. It is supposed to retrieve items from a “Projects” list based on my CAML query and render the returned items into a listbox. It works fine but everything gets returned. The filter is not really working. Any ideas?
Here’s my form:
Code:
2) How do I change “Web wb = site.RootWeb;” to really point to http://isaac.issharepoint.com/examples/.
I don’t want the root level “Projects” list. I want the “Projects” in the “examples” site. Yesterday, I kept getting an error and it went away when I created a “Projects” list at site collection level which is not the list I want.
Any ideas? Thanks for any help you can provide.
Here’s my form:
Code:
using (ClientContext ctx = new ClientContext("http://isaac.issharepoint.com/examples/"))
{
ctx.Credentials = new NetworkCredential("guest1", "xxxxxx#", "Sharepointroad");
Site site = ctx.Site; //Loads site collection into the site object
ctx.Load(site);
Web wb = site.RootWeb;
ctx.Load(wb);
ctx.ExecuteQuery(); //Go to the server and run all that has been loaded
//listBox1.Items.Add(ctx.Url);
//listBox1.Items.Add(site.Url);
List lst = wb.Lists.GetByTitle("Projects");
ctx.Load(lst);
ctx.ExecuteQuery();
listBox1.Items.Add(lst.Title);
CamlQuery query = new CamlQuery();
query.ViewXml = "<Query><Where><Eq><FieldRef Name='ProjNumber' /><Value Type='Text'>"+proj.Text.ToString()+"</Value></Eq></Where></Query>";
ListItemCollection all = lst.GetItems(query);
ctx.Load(all);
ctx.ExecuteQuery();
foreach (ListItem myList in all)
{
listBox1.Items.Add("Project Number: " + myList["ProjNumber"]);
listBox1.Items.Add(" Amount Projected: " + myList["AmtProjected"]);
listBox1.Items.Add(" Fiscal Year: "+myList["FiscalYear"]);
}
}
2) How do I change “Web wb = site.RootWeb;” to really point to http://isaac.issharepoint.com/examples/.
I don’t want the root level “Projects” list. I want the “Projects” in the “examples” site. Yesterday, I kept getting an error and it went away when I created a “Projects” list at site collection level which is not the list I want.
Any ideas? Thanks for any help you can provide.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.