hashtable 用法

来源:互联网 发布:spark大数据 编辑:程序博客网 时间:2024/06/06 19:15

 /// <summary>
    /// 一级地区
    /// </summary>
    /// <param name="pid"></param>
    /// <returns></returns>
    protected void diquBind(int pid)
    {
        secondDiqu = qd8.BLL.diqu.getbieming(pid);//获取地区别名
        string cacheKey = "cache" + pid;
        StringBuilder firstlist = new StringBuilder("");
        DataSet ds = null;
        //qd8.DBUtility.DataCache.RemoveCache(cacheKey);
        object obj = qd8.DBUtility.DataCache.GetCache(cacheKey);
       
        if (obj != null)
        {
            Hashtable ht = (Hashtable)obj;
            StringBuilder tem = new StringBuilder("");
            foreach (DictionaryEntry item in ht)
         {
                 string[] teStr = item.Value.ToString().Split('_');
                 string te = item.Key.ToString() == ViewState["dq"].ToString() ? "style=/"color:#ff0000;/"" : "";
                 tem.Append("<a " + te + " href=/"/" + menuName + "/" + item.Key + "/" + url + "//">" + teStr[0] + "</a>&nbsp;&nbsp;");
         }
            ltl_s_city.Text = tem.ToString();
        }
        else
        {
            ds = qd8.BLL.diqu.diqufenlei(pid.ToString());//根据父类id 获取该分类下子类列表
            if (ds.Tables[0].Rows.Count > 0)
            {
               
                Hashtable ht = new Hashtable();
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    string tempStr = row["title"] +"_"+ "0";//0否 1是 加红
                    ht.Add(row["directory"].ToString(), tempStr);
                }
                qd8.DBUtility.DataCache.SetCache(cacheKey, ht);
                this.ltl_s_city.Text = "<a style=/"color:#ff0000;/" href=/"/" + menuName + "/" + secondDiqu + "/" + url + "//">不限</a> " + firstlist.ToString() + dq.ToString();
            }
        }
    }

原创粉丝点击