using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace 選擇控件實例
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string strNum1, strNum2="";
string strLable;
strNum1 = RadioButtonList1.SelectedItem.ToString(); //取RadioButtonList1控件目前選中的值
foreach (ListItem item in CheckBoxList1.Items) //將CheckBoxList1控件中的值遍歷顯示在item中
{
if (item.Selected == true) //判斷item中的值哪些是被選中的
{
strNum2 = strNum2 + item.Text;
}
}
strLable = "你最想去的國家" + strNum1 + ",你喜歡的運動" + strNum2;
Label3.Text = strLable.ToString();
}
}
}