Microsoft.SharePoint.WebCon ...


DVCheckBoxList Class (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class DVCheckBoxList
    Inherits CheckBoxList
    Implements IDesignerEventAccessor
Visual Basic (Usage)
Dim instance As DVCheckBoxList
C#
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
public sealed class DVCheckBoxList : CheckBoxList, IDesignerEventAccessor
Inheritance Hierarchy

System.Object
   System.Web.UI.Control
     System.Web.UI.WebControls.WebControl
       System.Web.UI.WebControls.BaseDataBoundControl
         System.Web.UI.WebControls.DataBoundControl
           System.Web.UI.WebControls.ListControl
             System.Web.UI.WebControls.CheckBoxList
              Microsoft.SharePoint.WebControls.DVCheckBoxList
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Tags :


Community Content

Adam Buenz - MVP
DVCheckBoxList

Description

The Microsoft.SharePoint.WebControls.DVCheckBoxList class inherits from the System.Web.UI.WebControls.CheckBoxList class to create a data source bindable multi-selection check box list as well as the Microsoft.SharePoint.WebControls.IDesignerEventAccessor interface to contract two members, OnDesignerLoad and OnDesignerPreRender. Since the ASP.NET ControlDesigner doesn’t call OnLoad or OnPreRender when requesting control preview generation and OnInit and OnPreRender are both protected, the control designer can’t directly call OnInit and OnPreRender. Therefore the interface is used to circumvent this shortcoming. For the DVCheckBoxList the design lifecycle is particularly important because this control is exposed through SharePoint Designer.

DVCheckBoxList relies primarily on its CheckBoxList class inheritance for a majority of its functionality, however overriding the PerformDataBinding method and the SelectedValue property for full support in SharePoint Designer.

It should be noted that the because of the “DV” prefix on the DVCheckBoxList class name this class implies extension of a pre-existing SharePoint or ASP.NET class targeted for Data View (DV) usage.

Usage Scenario

The primary usage of the DVCheckBoxList control can be found with SharePoint Designer (SPD). Within the provided “SharePoint Controls” section in the SPD ToolBox, under the “Data View Controls” category the control is represented under the title “DataView CheckBox list”. Within managed code, the object finds little use since it is sealed so locked for inheritance, and trivial inheritance on the CheckBoxList class provides extension of further object attributes if required. However, use is analogous to any WebControl.

In the below example, MyClass is inheriting from the System.Web.UI.WebControls.WebParts.WebPart class and its CreateChildControls method is being overridden. Following, a new DVCheckBoxList object is being created with its ID property being set to something unique. The DVCheckBoxList.DataSourceID is set to an ID that represents a separate ObjectDataSource object and the DVCheckBoxList.DataBind method is being called. Subsequently, the hydrated control is being added to the current instance control collection.

C# Code Example

public class MyClass : WebPart
{
protected override void CreateChildControls()
{
DVDropDownList list = new DVDropDownList();
list.ID = "Drop Down List";
list.DataSourceID = "ListDataSource";
list.DataBind();
Controls.Add(list);
base.CreateChildControls();
}
}

VB.NET Code Example

Public Class [MyClass]
Inherits WebPart
Protected Overloads Overrides Sub CreateChildControls()
Dim list As New DVDropDownList()
list.ID = "Drop Down List"
list.DataSourceID = "ListDataSource"
list.DataBind()
Controls.Add(list)
MyBase.CreateChildControls()
End Sub
End Class
Tags :

Page view tracker