在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
ashx处理页 string JsonList = "["; IList<Models.Channel> ilist = BLL.ChannelManager.GetAllChannels(); List<Models.Channel> list = PublicCS.IListToList(ilist);/// IList转化为List JsonList += "{id:0,ChannelName:'顶级栏目'},"; foreach (Models.Channel channel in list) { JsonList += "{id:" + channel.Id.ToString() +",ChannelName:'" + channel.ChannelName + "'},"; } JsonList = JsonList.Substring(0, JsonList.Length - 1); JsonList += "]"; context.Response.Write("[{\"message\":\"成功\",\"ActionType\":\"" + action + "\",\"JsonList\":\"" + JsonList + "\",\"status\":\"success\"}]"); context.Response.End(); return; /// <summary> /// IList转化为List /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <returns></returns> public static List<T> IListToList<T>(IList<T> list) { T[] array = new T[list.Count]; list.CopyTo(array, 0); return new List<T>(array); }
html页面 <li><label>父级栏目</label><select id="ParentID"> </select> </li> JS var JsonList={}; JsonList =eval(data[0].JsonList);//将json数组转化为json对象 for(var i=0;i<JsonList.length;i++)//将json对象 绑定到select { $("#ParentID").append("<option value='"+JsonList[i].id+"'>"+JsonList[i].ChannelName+"</option>"); }
|
请发表评论