Csharp:jquery.ajax-combobox






JS object instead of DB: jquery.ajax-combobox






JS object instead of DB: jquery.ajax-combobox


   /// 
    /// $codebehindclassname$ 的摘要说明
    /// 塗聚文  涂聚文  Geovin Du
    /// 2019-7-22
    /// 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class AjaxComboxHandler : IHttpHandler
    {
        CountyTelCodeBLL telbll = new CountyTelCodeBLL();
        /// 
        /// 
        /// 
        /// 
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            List list = new List();
            CountyTelCode code = new CountyTelCode();
            //code.TelData().DefaultView.Sort = "IdOrder asc";
            //DataRow[] drs = code.TelData().Select("", "IdOrder asc");

            DataTable dt = telbll.SelectCountyTelCodeDataTableAll();

            foreach (DataRow row in dt.Rows)  //code.TelData().Rows
            {
                EntityCounty ec = new EntityCounty();
                ec.CountyCode = row["TelCoutyCode"].ToString().Trim();
                ec.name = row["SimpleNameHK"].ToString().Trim();
                ec.HkName = row["SimpleNameHK"].ToString().Trim();
                ec.CnName = row["SimpleNameCN"].ToString().Trim();                
                ec.EnName = row["SimpleNameEN"].ToString().Trim();
                ec.position = row["Continent"].ToString().Trim();
                ec.IdOrder = row["IdOrder"].ToString().Trim();
                list.Add(ec);
            }
            //序列化 JavaScriptSerializer
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string str = jss.Serialize(list);
            //返回
            context.Response.Write(str);        


            
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
        /// 
        /// 
        /// 
        /// 
        /// 
        private Dictionary JsonToDictionary(string jsonData)
        {
            //实例化JavaScriptSerializer类的新实例
            JavaScriptSerializer jss = new JavaScriptSerializer();
            try
            {
                //将指定的 JSON 字符串转换为 Dictionary 类型的对象
                return jss.Deserialize>(jsonData);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }

    /// 
    /// 
    /// 
    public class EntityCounty
    {

        private string _CountyCode;
     
        /// 
        ///    [ScriptIgnore] 为不显示
        /// 
        public string CountyCode
        {
            get { return _CountyCode; }
            set { _CountyCode = value; }
        }

        private string _name;
        /// 
        /// 
        /// 
        public string name
        {
            get { return _name; }
            set { _name = value; }
        }
        private string _EnName;
        /// 
        /// 
        /// 
        public string EnName
        {
            get { return _EnName; }
            set { _EnName = value; }
        }

        private string _CnName;
        /// 
        /// 
        /// 
        public string CnName
        {
            get { return _CnName; }
            set { _CnName = value; }
        }
        private string _HkName;
        /// 
        /// 
        /// 
        public string HkName
        {
            get { return _HkName; }
            set { _HkName = value; }
        }
        private string _position;
        /// 
        /// 
        /// 
        public string position
        {
            get { return _position; }
            set { _position = value; }
        }

        private string _IdOrder;
        /// 
        /// 
        /// 
        public string IdOrder
        {
            get { return _IdOrder; }
            set { _IdOrder = value; }
        }
    }

  

你可能感兴趣的:(Csharp:jquery.ajax-combobox)