栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > asp

ajax.net +jquery 无刷新三级联动的实例代码

asp 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ajax.net +jquery 无刷新三级联动的实例代码

复制代码 代码如下:
   


   
   
   


   省:
   
    市:
   
    县:
   



webservice:

复制代码 代码如下:
 [WebMethod]//加载省
        public List loadprovince()//为什么要用list因为这里出从前的值不可能一个实例是多个model实例,一个实例就是一条记载这样做防止字段错误
        {
            BLL.province bp = new BLL.province();
            List list=bp.getlistModel();
            return list;
        }
        [WebMethod]//加载市
        public List loadcity(string fatherid)
        {
            BLL.city bc = new BLL.city();
            List list = bc.getlistmodel(fatherid);
            return list;
        }
        [WebMethod]//加载县
        public List loadarea(string fatherid)
        {
            BLL.area ba = new BLL.area();
            List list = ba.getlistmodel(fatherid);
            return list;

        }
    }
}

DAL--area

复制代码 代码如下:
public System.Collections.Generic.List getlistmodel(string fatherid)
        {
            System.Collections.Generic.List list = new System.Collections.Generic.List();
            DataTable dt = GetList("father=" + fatherid + "").Tables[0];
            foreach (DataRow row in dt.Rows)
            {
                Model.area ma = new Model.area();
                ma.areaID = row["areaID"].ToString();
                ma.areaname = row["areaname"].ToString();
                ma.father = row["father"].ToString();
                list.Add(ma);
            }
            return list;
        }


Dal--city

复制代码 代码如下:
 public System.Collections.Generic.List getlistmodel(string fatherid)
        {
            System.Collections.Generic.List list = new System.Collections.Generic.List();
            DataTable dt = GetList("father=" + fatherid + "").Tables[0];
            foreach (DataRow row in dt.Rows)
            {
                Model.area ma = new Model.area();
                ma.areaID = row["areaID"].ToString();
                ma.areaname = row["areaname"].ToString();
                ma.father = row["father"].ToString();
                list.Add(ma);
            }
            return list;
        }
    }


DAL-provience

复制代码 代码如下:
public System.Collections.Generic.List getlistModel()
        {
            //将要查的内容以实例的方式返回
            //这里要做的就是要建立list并将list用model实例填满,而model要用一个方法失掉数据并添加到model中
          //建list实例
            System.Collections.Generic.List list = new System.Collections.Generic.List();
            //已经有了的失掉数据的方法就不用自己写了通过调用Getlist的方法操纵数据库拿到数据
            DataTable dt = GetList("").Tables[0];
            //拿到数据后就需要将数据添加到model实例中了

            foreach (DataRow row in dt.Rows)
            {
                //每一行都是个实例所以要将model的放在循环里面
                Model.province mp = new Model.province();
                mp.provinceID = row["provinceID"].ToString();
                mp.provincename = row["provincename"].ToString();
                list.Add(mp);//没添加完一个实例都要放到list中
            }
            return list;


        }

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/57689.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号