zoukankan      html  css  js  c++  java
  • checkboxlist 多选项获值

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    
    namespace CSCDF.Web
    {
        public partial class test : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack) 
                {
                    BindchkCountry();
                }
                
            }
            protected void BindchkCountry()
            {
                CSCDF.BLL.Country countrybll = new CSCDF.BLL.Country();
                DataSet ds = new DataSet();
                ds = countrybll.GetList("");
                chkCountry.DataTextField = "CountryName";
                chkCountry.DataValueField = "CountryID";
                chkCountry.DataSource = ds;
                chkCountry.DataBind();
            }
    
            protected void btnTest_Click(object sender, EventArgs e)
            {
                string s="";
                for (int i = 0; i < chkCountry.Items.Count; i++)
                {
                    if (chkCountry.Items[i].Selected) 
                    {
                        s += chkCountry.Items[i].Value.Trim()+"|";
                    }   
                } 
    
                Maticsoft.Common.MessageBox.Show(this,s);
            }
        }
    }
    用心写代码,不辜负程序员之名。
  • 相关阅读:
    前端线上项目汇总
    gulp构建工具学习汇总
    ES6知识点汇总
    页游技术点汇总中
    前后端方案汇总
    vim常用命令
    互联网哲学
    js调试技巧汇总中
    windows下Docker安装MySQL
    RabbitMQ几个常用面试题
  • 原文地址:https://www.cnblogs.com/thinkingthigh/p/3044673.html
Copyright © 2011-2022 走看看