This topic has not yet been rated - Rate this topic

DVRadioButtonList Class

Represents a radio button list component for a data view.

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.RadioButtonList
              Microsoft.SharePoint.WebControls.DVRadioButtonList

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class DVRadioButtonList : RadioButtonList, 
	IDesignerEventAccessor
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
DVRadioButtonList
Description

The Microsoft.SharePoint.WebControls.DVRadioButtonList class inherits from the System.Web.UI.WebControls.CheckBoxList class to create a data source bindable multi-selection check box represented by RadioButtons 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 DVRadioButtonList the design lifecycle is particularly important because this control is exposed through SharePoint Designer.

DVRadioButtonList relies primarily on its RadioButtonList 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 DVRadioButtonList 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 DVRadioButtonList 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 Radio Button list”.Within managed code, the object finds little use since it is sealed so locked for inheritance, and trivial inheritance on the RadioButtonList 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 DVRadioButtonList object is being created with its ID property being set to something unique. The DVRadioButtonList.DataSourceID is set to an ID that represents a separate ObjectDataSource object which has been created with a specified typename and select method and added to the control collection. Following, the DVRadioButtonList.DataBind method is 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()
        {
            ObjectDataSource mySource = new ObjectDataSource("MyType", "SelectMethod");
            mySource.ID = "ListDataSource";
            Controls.Add(mySource);
            DVRadioButtonList list = new DVRadioButtonList();
            list.ID = "RadioButtonList";
            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 mySource As New ObjectDataSource("MyType", "SelectMethod")
        mySource.ID = "ListDataSource"
        Controls.Add(mySource)
        Dim list As New DVRadioButtonList()
        list.ID = "RadioButtonList"
        list.DataSourceID = "ListDataSource"
        list.DataBind()
        Controls.Add(list)
        MyBase.CreateChildControls()
    End Sub
End Class
 
Adam Buenz
SharePoint Services MVP - http://www.sharepointsecurity.com