Online Training On SharePoint
                      

Question on List Data

Question 76: To fetch all the data from a SharePoint list to a DataTable the correct code snippet would be:

a. SPSite site = new SPSite(http://servername:12345/);
SPWeb web = new SPWeb();
web = site.OpenWeb();
SPList list = web.Lists[“ListName”];
DataTable tblItems = list.GetDataTable();

b. SPSite site = new SPSite(http://servername:12345/);
SPWeb web = new SPWeb();
SPList list = web.Lists[“ListName”];
DataTable tblItems = list.Items.GetDataTable();

c. SPSite site = new SPSite(http://servername:12345/);
SPWeb web = new SPWeb();
web = site.OpenWeb();
SPList list = web.Lists[“ListName”];
DataTable tblItems = list.Items.GetDataTable();

d. SPSite site = new SPSite(http://servername:12345/);
SPWeb web = new SPWeb();
web = site.OpenWeb();
SPList list = web.Lists[“ListName”];
DataTable tblItems = list.Items.GetTable();

Check Answer