Which code segment should you insert at line 03?

You create a Microsoft Windows SharePoint Services application. A SharePoint site has a list named MyList. You write the following code segment. (Line numbers are included for reference only.)

01 Dim site As SPWeb = SPControl.GetContextWeb(context)
02 Dim list As SPList = site.Lists(“MyList”)
03 …

You need to bind the list to a DataGrid control. You also need to ensure that all the fields in the list are available in the DataTable object.

Which code segment should you insert at line 03?

You create a Microsoft Windows SharePoint Services application. A SharePoint site has a list named MyList. You write the following code segment. (Line numbers are included for reference only.)

01 Dim site As SPWeb = SPControl.GetContextWeb(context)
02 Dim list As SPList = site.Lists(“MyList”)
03 …

You need to bind the list to a DataGrid control. You also need to ensure that all the fields in the list are available in the DataTable object.

Which code segment should you insert at line 03?

A.
Dim listItems As SPListItemCollection = list.Items
Dim table As DataTable = listItems.GetDataTable()

B.
Dim listItems As SPListItemCollection = list.Items
For Each item As SPListItem In listItems
item.Properties(“Visible”) = True
Next
Dim table As DataTable = listItems.GetDataTable()

C.
Dim listItems As SPListItemCollection = list.Items
Dim table As DataTable = New DataTable()
For Each item A s SPListItem In listItems
Dim col As DataColumn = New DataColumn(item.Name)
col.ExtendedProperties(“Visible”) = True
table.Columns.Add(col)
Next

D.
Dim dataViewGuid As Guid = list.Views(“DataView”).ID
Dim srcView As SPView = list.GetView(dataViewGuid)
Dim viewFields As SPViewFieldCollection = srcView.ViewFields
Dim listItems As SPListItemCollection = list.GetItems(srcView)
Dim table As DataTable = listItems.GetDataTable()



Leave a Reply 0

Your email address will not be published. Required fields are marked *