RadioButtonList 控件表示一個封裝了一組單選按鈕控件的列表控件。
可以使用兩種類型的 ASP.NET 控件將單選按鈕添加到網頁上:各個 RadioButton 控件或一個 RadioButtonList 控件。這兩類控件都允許用戶從一小組互相排斥的預定義選項中進行選擇。使用這些控件,可定義任意數目的帶標簽的單選按鈕,並將它們水平或垂直排列。
一、常用屬性
屬性
值
作用
RepeatDirection
Horizontal|Vertical
項的布局方向:水平方向|豎直風向
RepeatLayout
Table|Flow
展現方式:表格|流線型
Selected
True|Falsee
是否為選中狀態
二、代碼演示
前台 RadioButtonList.aspx
復制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadioButtonList.aspx.cs" Inherits="WebControls_RadioButtonList" %>
後台 RadioButtonList.aspx.cs
復制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class WebControls_RadioButtonList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblState.Text = radlSex.SelectedValue;
}
}