Exemplo n.º 1
0
    //分类下拉
    private void BindItemTypeListBox()
    {
        DataTable dt = new DataTable();

        if (Cache["itemtype"] != null)
        {
            dt = (DataTable)Cache["itemtype"];
        }
        else
        {
            dt = bll.GetListBoxData(userId, "ItemTypeName", "ItemType", "DESC");
            CacheHelper.AddCache("itemtype", dt, CacheItemPriority.Normal);
        }
        this.ItemTypeListBox.DataSource     = dt;
        this.ItemTypeListBox.DataTextField  = "ItemTypeName";
        this.ItemTypeListBox.DataValueField = "ItemType";
        this.ItemTypeListBox.DataBind();

        string[] arr = itemType.Split(',');
        foreach (ListItem item in this.ItemTypeListBox.Items)
        {
            if (itemType == "")
            {
                item.Selected = true;
            }
            foreach (string str in arr)
            {
                if (item.Value == str)
                {
                    item.Selected = true;
                }
            }
        }
    }