Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How many methods to get list using sharepoint object model

$
0
0

I want to know what is the difference between the following two code snippets while getting list from sharepoint

SPList list = oSPWeb.Lists["MyList"];
            //Add a new item in the List
            SPListItem itemToAdd = list.Items.Add();
            itemToAdd["Title"] = "Test Title";
            itemToAdd["Description"] = "Test Description";
            itemToAdd.Update();


and

SPListItemCollection listItemsCol = myweb.Lists["Employee_Details"].Items;
SPListItem item = listItemsCol.Add();
item["EmployeeName"] = txtEmployeeName.Text;
item["Title"] = txtDesi.Text;
item["EmployeeID"] = Convert.ToInt32(txtEmployeeID.Text);
item.Update();

Why first code snippet uses only SPList to get sharePoint list

and in second code snippet why we used SPListItemCollection?


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>