PowerWEB LiveControls for ASP.NET
SelectedIndex Property
See Also  Send comments on this topic.
Dart.LiveControls Namespace > LiveRadioButtonList Class : SelectedIndex Property



Gets or sets the lowest ordinal index of the selected items in the list.

Syntax

Visual Basic (Declaration) 
Public Overrides Property SelectedIndex As Integer
Visual Basic (Usage)Copy Code
Dim instance As LiveRadioButtonList
Dim value As Integer
 
instance.SelectedIndex = value
 
value = instance.SelectedIndex
C# 
public override int SelectedIndex {get; set;}
C++/CLI 
public:
property int SelectedIndex {
   int get() override;
   void set (    int value) override;
}

Example

The following example demonstrates using a LiveMessageBox in combination with a Live List control.
Visual BasicCopy Code
'In this example, items are added to a Live List control using an ArrayList when a LiveButton is pressed
'The items include different LiveMessageBox Dialog Types
'When one of the Types is selected in the List, the MessageBox is shown
'LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList

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
    LiveList1.DataSource = arrayItems
    LiveList1.DataBind()
End Sub

Private Sub LiveList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveList1.SelectedIndexChanged
    'When a type of MessageBox is selected from the list, show it 
    Select Case (LiveList1.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
C#Copy Code
//In this example, items are added to a Live List control using an ArrayList when a LiveButton is pressed
//The items include different LiveMessageBox Dialog Types
//When one of the Types is selected in the List, the MessageBox is shown
//LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList

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
	LiveList1.DataSource = arrayItems;
	LiveList1.DataBind();
}

private void LiveList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	//When a type of MessageBox is selected from the list, show it 
	switch (LiveList1.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;	
	}
}

Remarks

This member is functionally equivalent to System.Web.UI.WebControls.ListControlClass.SelectedIndex.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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