可以这么写吧?为什么进不了switch里面呢?我跟踪catalog得到的字符串就是这三个中的一个 啊,但就是都进不去
string catalog = Request.Params["Catalog"].ToString();
            string productID = Request.Params["ProductID"];
            //Response.Write(catalog);
            switch (catalog)
            {
                case "News":
                    Server.Transfer("NewsInfo.aspx");
                    break;
                case "Movie":
                    if (Request.Params["ProductID"] != null)
                    {
                        BindProductData(productID, catalog);
                    }
                    break;
                case "Music":
                    Server.Transfer("MusicInfo.aspx");
                    break;
                default:
                    break;
            }

解决方案 »

  1.   

    请你仔细检查一下,确定前后有无空格以及大小写等!!
    建议使用:
    string product = Request.Params["ProductID"].Trim();
      

  2.   

    是不是有空格沒看出來??加Trim 試一試
      

  3.   


       switch (catalog.Trim())
                {
                    case "News":
                        Server.Transfer("NewsInfo.aspx");
                        break;
                    case "Movie":
                        if (Request.Params["ProductID"] != null)
                        {
                            BindProductData(productID, catalog);
                        }
                        break;
                    case "Music":
                        Server.Transfer("MusicInfo.aspx");
                        break;
                    default:
                        break;
                }