SPDocDiscussionCollection.Item Property

NOTE: This API is now obsolete.

Gets the document discussion object at the specified index in the collection. In Microsoft Visual C#, this property is the indexer for the collection of the SPDocDiscussionCollection class.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<ObsoleteAttribute("SPDocDiscussionCollection is deprecated", False)> _
Public ReadOnly Property Item ( _
    index As Integer _
) As SPDocDiscussion
    Get
'Usage
Dim instance As SPDocDiscussionCollection
Dim index As Integer
Dim value As SPDocDiscussion

value = instance.Item(index)
[ObsoleteAttribute("SPDocDiscussionCollection is deprecated", false)]
public SPDocDiscussion this[
    int index
] { get; }

Parameters

  • index
    Type: System.Int32

    A 32-bit integer that specifies the index of the object.

Property Value

Type: Microsoft.SharePoint.SPDocDiscussion
A Microsoft.SharePoint.SPDocDiscussion object that represents the iscussion object.

Remarks

The Item property throws an ArgumentOutOfRangeException exception if the specified index is outside the valid range of indexes for the collection.

Examples

The following code example iterates through all the document libraries of a site collection and uses the indexer to display the URL for each document that has a discussion associated with it.

The example assumes the existence of an .aspx page that contains a label control.

Dim siteCollection As SPSite = SPContext.Current.Site
Dim subSites As SPWebCollection = siteCollection.AllWebs
Dim site As SPWeb

For Each site In  subSites

    Dim lists As SPListCollection = site.Lists
    Dim list As SPList

    For Each list In  lists

        If list.BaseType.ToString() = "DocumentLibrary" Then

            Dim discs As SPDocDiscussionCollection 
                = site.GetDocDiscussions(list.Title)

            If discs.Count > 0 Then

                Dim i As Integer

                For i = 0 To discs.Count - 1

                    Label1.Text += discs(i).DocUrl + "<BR>"
                Next i
            End If
        End If
    Next list
Next site 
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;

foreach (SPWeb oWebsite in collWebsites)
{
    SPListCollection collLists = oWebsite.Lists;

    foreach (SPList oList in collLists)
    {
        if (oList.BaseType.ToString() == "DocumentLibrary")
        {
            SPDocDiscussionCollection collDocDiscussions = oWebsite.GetDocDiscussions(oList.Title);

            if (collDocDiscussions.Count > 0)
            {
                for (int intIndex = 0; intIndex < collDocDiscussions.Count; intIndex++)
                {
                    Label1.Text += collDocDiscussions[intIndex].DocUrl
                        + "<BR>";
                }
            }
        }
    }
    oWebsite.Dispose();
}

Note

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

See Also

Reference

SPDocDiscussionCollection Class

SPDocDiscussionCollection Members

Microsoft.SharePoint Namespace