//第一種方法
        foreach (Control ct in form1.Controls)
        {
            if (ct.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
            {
                CheckBox cb = (CheckBox)ct;
                if (cb.Checked == true)
                {
                    Response.Write(cb.Text);
                }
            }
        }

 //第二種方法
        foreach (Control ct in form1.Controls)
        {
            if (ct.GetType().ToString().Equals("System.Web.UI.HtmlControls.HtmlInputCheckBox")) 
            {
                HtmlInputCheckBox cb = (HtmlInputCheckBox)ct;
                if (cb.Checked == true)
                {
                    Response.Write(cb.Value);
                }
            }
        }

goodlucky 發表在 痞客邦 PIXNET 留言(0) 人氣()