hashtable 用法

 /// <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();
            }
        }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值