PowerWEB LiveControls for ASP.NET
LiveRadioButtonList Class
Members  Example  See Also  Send comments on this topic.
Dart.LiveControls Namespace : LiveRadioButtonList Class



Represents a list control that encapsulates a group of radio button controls.

Syntax

Visual Basic (Declaration) 
<LicenseProviderAttribute(System.ComponentModel.LicenseProvider)>
Public Class LiveRadioButtonList 
   Inherits System.Web.UI.WebControls.RadioButtonList
   Implements ILiveControl 
Visual Basic (Usage)Copy Code
Dim instance As LiveRadioButtonList
C# 
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)]
public class LiveRadioButtonList : System.Web.UI.WebControls.RadioButtonList, ILiveControl  
C++/CLI 
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)]
public ref class LiveRadioButtonList : public System.Web.UI.WebControls.RadioButtonList, ILiveControl  

Example

The following example demonstrates different ways of adding items to a Live List control.
Visual BasicCopy Code
'In the following examples, items are added to all four types of Live List controls
'These include the LiveListBox, LiveDropDownList, LiveRadioButtonList and LiveCheckBoxList
'Each Live List control can be interchanged with another

'Add items using an ArrayList, and show a LiveMessageBox when an item is selected

Private Sub LiveButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton1.Click
    'Create a new ArrayList with the items to add to the Live list control
    Dim arrayItems As New ArrayList()
    arrayItems.Add("Alert")
    arrayItems.Add("Confirm")
    arrayItems.Add("Prompt")

    'Set the data source to the ArrayList and bind it to the Live list control
    LiveRadioButtonList1.DataSource = arrayItems
    LiveRadioButtonList1.DataBind()
End Sub

Private Sub LiveRadioButtonList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveRadioButtonList1.SelectedIndexChanged
    'When a type of MessageBox is selected from the list, show it 
    Select Case (LiveRadioButtonList1.SelectedIndex)
    Case 0
        LiveMessageBox1.Show("You have selected 'Alert'", DialogType.Alert)
        Case 1
        LiveMessageBox1.Show("You have selected 'Confirm'", DialogType.Confirm)
        Case 2
        LiveMessageBox1.Show("You have selected 'Prompt'", DialogType.Prompt)
        Case Else
    End Select
End Sub

Private Sub LiveMessageBox1_Response(ByVal sender As Object, ByVal e As ResponseEventArgs) Handles LiveMessageBox1.Response
    'After Confirm and Prompt MessageBoxes are shown, the Response event will fire

    'If it is a Confirm box, indicate which button was pressed in a LiveTextBox
    If (e.DialogType = DialogType.Confirm) Then
        If (e.Confirmed) Then
        LiveTextBox1.Text = "The OK button was pressed"
        Else
        LiveTextBox1.Text = "The Cancel button was pressed"
        End If

        'If it is a Prompt box, show the input data (or indicate the prompt was cancelled) in a LiveTextBox
    ElseIf (e.DialogType = DialogType.Prompt) Then
        If (Not e.Confirmed) Then
        LiveTextBox1.Text = "The Prompt was cancelled"
        Else
        LiveTextBox1.Text = "The inputted data was: " + e.Text
        End If
    End If
End Sub


'Add items dynamically, when a LiveButton is pressed

Private Sub LiveButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton2.Click
    'Add items dynamically in code to a list control
    'When the LiveButton is pressed, a new item is added to the list
    LiveListBox1.Items.Add(DateTime.Now.ToString())
End Sub

Private Sub LiveListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveListBox1.SelectedIndexChanged
    'A LiveLabel is updated whenever an item is selected from the list
    LiveLabel1.Text = "This item was added at " + LiveListBox1.Items(LiveListBox1.SelectedIndex).ToString()
End Sub


'Add items from a database, and display an image when an item is selected

Private Sub LiveButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton3.Click
    'Make sure that System.Data.OleDb is used

    'Get Items from a Database "images.mdb" in the folder "database"
    'The table is called "Table1" and the column with the filenames is "filename"
    Dim connection As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/images.mdb"))
    Dim sql As String = "SELECT filename FROM Table1"
    Dim adapter As New OleDbDataAdapter(sql, connection)
    Dim dataSet As New DataSet("imagesDataSet")
    adapter.Fill(dataSet, "images")

    'Bind the database to the Live List
    LiveDropDownList1.DataSource = dataSet
    LiveDropDownList1.DataMember = "images"
    LiveDropDownList1.DataTextField = "filename"
    LiveDropDownList1.DataBind()

    'Set a starting image, and show it by executing the SelectedIndexChanged event handler
    LiveDropDownList1.SelectedIndex = 0
    LiveDropDownList1_SelectedIndexChanged(Me, Nothing)
End Sub

Private Sub LiveDropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveDropDownList1.SelectedIndexChanged
    'The Live List has been populated with some image filenames
    'When a new item is selected in the list, the new image is displayed
    LiveImage1.AlternateText = "Could not display selected image."
    LiveImage1.ImageUrl = "images/" + LiveDropDownList1.SelectedItem.Text
End Sub


'Add items to the Items.Collection and play a sound when an item is selected

Private Sub LiveButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton4.Click
    'Add items to the Live list control via the ListItemCollection
    LiveCheckBoxList1.Items.Add("chord.wav")
    LiveCheckBoxList1.Items.Add("chimes.wav")
    LiveCheckBoxList1.Items.Add("exclamation.wav")
    LiveCheckBoxList1.Items.Add("error.wav")
End Sub

Private Sub LiveCheckBoxList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveCheckBoxList1.SelectedIndexChanged
    'When an item in the LiveCheckBoxList is selected or de-selected
    'The selected sound that is topmost in the list will play
    If (LiveCheckBoxList1.SelectedIndex > -1) Then
        LiveSound1.Source = "sounds/" + LiveCheckBoxList1.Items(LiveCheckBoxList1.SelectedIndex).ToString()
        LiveSound1.Play()
    End If
End Sub
C#Copy Code
//In the following examples, items are added to all four types of Live List controls
//These include the LiveListBox, LiveDropDownList, LiveRadioButtonList and LiveCheckBoxList
//Each Live List control can be interchanged with another

//Add items using an ArrayList, and show a LiveMessageBox when an item is selected

private void LiveButton1_Click(object sender, System.EventArgs e)
{
	//Create a new ArrayList with the items to add to the Live list control
	ArrayList arrayItems = new ArrayList();
	arrayItems.Add("Alert");
	arrayItems.Add("Confirm");
	arrayItems.Add("Prompt");

	//Set the data source to the ArrayList and bind it to the Live list control
	LiveRadioButtonList1.DataSource = arrayItems;
	LiveRadioButtonList1.DataBind();
}

private void LiveRadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	//When a type of MessageBox is selected from the list, show it 
	switch (LiveRadioButtonList1.SelectedIndex)
	{
		case 0:
			LiveMessageBox1.Show("You have selected 'Alert'!", DialogType.Alert);
			break;
		case 1:
			LiveMessageBox1.Show("You have selected 'Confirm'!", DialogType.Confirm);
			break;
		case 2:
			LiveMessageBox1.Show("You have selected 'Prompt'!", DialogType.Prompt);
			break;
		default:
			break;
	}
}

private void LiveMessageBox1_Response(object sender, ResponseEventArgs e)
{
	//After Confirm and Prompt MessageBoxes are shown, the Response event will fire

	//If it is a Confirm box, indicate which button was pressed in a LiveTextBox
	if (e.DialogType == DialogType.Confirm)
	{
		if (e.Confirmed)
			LiveTextBox1.Text = "The OK button was pressed!";
		else
			LiveTextBox1.Text = "The Cancel button was pressed!";
	}
	//If it is a Prompt box, show the input data (or indicate the prompt was cancelled) in a LiveTextBox
	else if (e.DialogType == DialogType.Prompt)
	{
		if (!e.Confirmed)
			LiveTextBox1.Text = "The Prompt was cancelled!";
		else
			LiveTextBox1.Text = "The inputted data was: " + e.Text;	
	}
}

//Add items dynamically, when a LiveButton is pressed

private void LiveButton2_Click(object sender, System.EventArgs e)
{
	//Add items dynamically in code to a list control
	//When the LiveButton is pressed, a new item is added to the list
	LiveListBox1.Items.Add(DateTime.Now.ToString());
}

private void LiveListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	//A LiveLabel is updated whenever an item is selected from the list
	LiveLabel1.Text = "This item was added at " + LiveListBox1.Items[LiveListBox1.SelectedIndex];
}


//Add items from a database, and display an image when an item is selected

private void LiveButton3_Click(object sender, System.EventArgs e)
{
	//Make sure that System.Data.OleDb is used

	//Get Items from a Database "images.mdb" in the folder "database"
	//The table is called "Table1" and the column with the filenames is "filename"
	OleDbConnection connection = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/images.mdb"));
	string sql = "SELECT filename FROM Table1";
	OleDbDataAdapter adapter = new OleDbDataAdapter(sql, connection);
	DataSet dataSet = new DataSet("imagesDataSet");
	adapter.Fill(dataSet, "images");
			
	//Bind the database to the Live List
	LiveDropDownList1.DataSource = dataSet;
	LiveDropDownList1.DataMember = "images";
	LiveDropDownList1.DataTextField = "filename";
	LiveDropDownList1.DataBind();

	//Set a starting image, and show it by executing the SelectedIndexChanged event handler
	LiveDropDownList1.SelectedIndex = 0;
	LiveDropDownList1_SelectedIndexChanged(this, null);
}

private void LiveDropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	//The Live List has been populated with some image filenames
	//When a new item is selected in the list, the new image is displayed
	LiveImage1.AlternateText = "Could not display selected image.";
	LiveImage1.ImageUrl = "images/" + LiveDropDownList1.SelectedItem.Text;
}

//Add items to the Items.Collection and play a sound when an item is selected
		
private void LiveButton4_Click(object sender, System.EventArgs e)
{
	//Add items to the Live list control via the ListItemCollection
	LiveCheckBoxList1.Items.Add("chord.wav");
	LiveCheckBoxList1.Items.Add("chimes.wav");
	LiveCheckBoxList1.Items.Add("exclamation.wav");
	LiveCheckBoxList1.Items.Add("error.wav");
}

private void LiveCheckBoxList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	//When an item in the LiveCheckBoxList is selected or de-selected
	//The selected sound that is topmost in the list will play
	if (LiveCheckBoxList1.SelectedIndex > -1)
	{
		LiveSound1.Source = "sounds/" + LiveCheckBoxList1.Items[LiveCheckBoxList1.SelectedIndex];
		LiveSound1.Play();
	}
}

Remarks

This member is functionally equivalent to System.Web.UI.WebControls.RadioButtonListClass.

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.RadioButtonList
                     Dart.LiveControls.LiveRadioButtonList

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.0.2
© 2012 Dart Communications. All Rights Reserved.