Click here to Skip to main content
15,914,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How to get all items in list from sharepoint List using c#. Please Help me to solve this problem.

I am write code this code but its get only list item count.try to get list items but not working.

C#
ClientContext context = new ClientContext("http://sezdmc445//_vti_bin/lists.asmx");
NetworkCredential cred = new NetworkCredential();
cred.UserName = "spadmin";
cred.Password = "abc@1234";
//context.UseDefaultCredentials = false;
context.Credentials = cred;
context.Load(context.Web);
context.Load(context.Web.Lists);         
context.ExecuteQuery();
Web web = context.Web;
ListCollection lists = context.Web.Lists;       
string abc = "DL_ABCD";
foreach (List list in lists)
{
    if (list.Title ==  abc )
    {
        string lisiitem12 = list.ItemCount.ToString();           
        MessageBox.Show(lisiitem12);
        MessageBox.Show(list.Title);        
    }
}
Posted
Updated 2-May-13 23:14pm
v5
Comments
Sandeep Mewara 2-May-13 9:51am    
What have you tried so far?
lukeer 3-May-13 2:48am    
What exactly is not working?
Do you get any error messages?
Can you narrow down what code line causes the error?

Nothing to do with your question, but you construct a StringBuilder instance using string concatenation. That's what the use of StringBuilder usually is there to prevent. Do you use it more afterwards?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900