productcategorieslist.ascx.cs

来自「易想商城系统」· CS 代码 · 共 79 行

CS
79
字号
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Text;

namespace YXShop.Web.Admin.Product.Control
{
    public partial class ProductCategoriesList : System.Web.UI.UserControl
    {
        protected string SelectList;
        private string strProID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            SelectContent();
        }
        public string StrProID
        {
            get
            {
                return (strProID == null) ? "" : strProID;
            }
            set { strProID = value; }
        }
        protected void SelectContent()
        {
            YXShop.BLL.Pro_Brand dataB = new YXShop.BLL.Pro_Brand();
            YXShop.BLL.Pro_Categories data = new YXShop.BLL.Pro_Categories();
            List<YXShop.Model.Pro_Categories> Ldata = data.GetAll();
            StringBuilder shtml = new StringBuilder();
            shtml.Append("<select id=\"ProductCategories\" name=\"ProductCategories\" size=\"8\" multiple width=\"400px\">");
            if (Ldata.Count > 0)
            {

                int j = 0;
                foreach (YXShop.Model.Pro_Categories ds in Ldata)
                {
                    string[] Path = ds.ProC_ParentPath.ToString().Split(',');
                    string KG = "";
                    for (int i = 1; i < Path.Length; i++)
                    {
                        KG += "&nbsp;&nbsp;";
                    }
                    if (StrProID != string.Empty)
                    {
                        //修改品牌信息时判断产品分类是否选中
                        string[] ParentPath = StrProID.Split(',');
                        
                        if (j < ParentPath.Length && ParentPath[j].ToString() == ds.ProC_ID.ToString())
                        {

                            shtml.Append("<option value=" + ds.ProC_ID + " selected>" + KG + "├" + ds.ProC_CategroiesName + "</option>");
                            j++;
                        }
                        else
                        {
                            shtml.Append("<option value=" + ds.ProC_ID + " >" + KG + "├" + ds.ProC_CategroiesName + "</option>");
                        }
                    }
                    else
                    {
                        shtml.Append("<option value=" + ds.ProC_ID + " >" + KG + "├" + ds.ProC_CategroiesName + "</option>");
                    }
                }
            }
            shtml.Append("</select>");
            SelectList = shtml.ToString();
        }


    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?