日期:2014-05-20  浏览次数:20644 次

小弟愚蠢,这个功能只实现一半,实在苦恼!
小弟愚蠢,这个功能只实现一半,实在苦恼!

做了一两天了,跟这个网站的产品筛选功能类似的。
http://sports.8t8x.com/product/yumaoqiu.htm
下面的代码我只能处理URL参数里有的字段,让它不追加重复的筛选ID,但是同类的切无法让它不追加,比如
"材质分类:"这个选项里有"碳素纤维 铝合金 铝碳一体 铁合金"
我选了碳素纤维,碳素纤维的ID是1。现在再选铝合金,铝合金的URL参数不应该包含1的。可是我无法实现

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MTC.Web.Aspx
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string allSelectField = "48,49,-48,50,-48,51,-|45,46,-45,47,-|2,3,-2,4,-2,5,-2,29,-2,30,-2,31,-2,32,-2,33,-2,34,-2,35,-2,36,-2,37,-|1,6,-

1,7,-1,52,-1,53,-|8,9,-8,10,-8,11,-|38,39,-38,40,-38,41,-|42,43,-42,44,-|";
            allSelectField = allSelectField.Replace(",-|", "|");
            allSelectField = allSelectField.Replace(",-", "-");
            allSelectField = allSelectField.Substring(0,allSelectField.Length - 1);
            string[] groupArray = allSelectField.Split('|');  //组数组
            string[] fieldArray; //大类数组
            string[] SmallFieldArray; //小类数组

            string url = "50-46-29"; //提交的查询URL
            string[] urlArray = url.Split('-');  //URL数组
            Response.Write("URL is:" + url + "<br />");
            for (int i = 0; i < groupArray.Length; i++) //遍历组
            {
                fieldArray = groupArray[i].Split('-');
                for (int ii = 0; ii < fieldArray.Length; ii++)//遍历大类
                {
                    SmallFieldArray = fieldArray[ii].Split(',');
                    Response.Write(myTest2(url, urlArray, SmallFieldArray, fieldArray[ii], groupArray[i]));
                }
            }

        }

        /// <summary>
        /// 
        /// </summary>