大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Csharp:asp.netCheckBoxListdatabind

我们提供的服务有:成都网站设计、网站制作、微信公众号开发、网站优化、网站认证、集美ssl等。为上千企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的集美网站制作公司


        

/// 
        /// CheckBoxList數據源
        /// 塗聚文
        /// 20130705
        ///
        /// 
        private void setCheckBoxList()
        {
           DataTable dt = new DataTable();
           CheckBoxList1.Items.Clear();
          dt = geovindu_branchBLL.SelectGeovindu_branchNameDt();
          CheckBoxList1.DataSource = dt;
          this.CheckBoxList1.DataTextField = "B_Name";
          this.CheckBoxList1.DataValueField = "B_EnglishName";
          CheckBoxList1.DataBind();
        }
        /// 
        ///
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                setCheckBoxList();
            }
        
        }
        /// 
        /// 獲取選擇的項目
        /// 
        /// 
        /// 
        protected void Button1_Click(object sender, EventArgs e)
        {
            string variable = string.Empty;
            int i = 0;
            foreach (System.Web.UI.WebControls.ListItem oItem in CheckBoxList1.Items)
            {
                if (oItem.Selected) // if you want only selected
                {
                    if (i ==0)
                    {
                       variable = oItem.Value;
                    }
                    else
                    {
                        variable = variable + "," + oItem.Value;
                    }
                    i++;
                }
                // otherwise get for all items
                //variable = oItem.Value;
                  
            }
            //傳值給父頁面
            this.Page.Controls.Add(new LiteralControl(string.Format("", variable)));
       
             //關閉此視窗
            this.Page.Controls.Add(new LiteralControl(""));

本文标题:Csharp:asp.netCheckBoxListdatabind
转载源于:http://dzwzjz.com/article/pcdice.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP