0

假设我有带有以下超链接的子页面

http://localhost:7621/PDWv1.0.4/ProductList.aspx?categoryID=2

ProductList.aspx 的页面加载如下(Page_Load 部分)

if (!Page.IsPostBack)
    {
        l_categoryParseId = Request.QueryString["categoryID"];
        if (l_categoryParseId == null || l_categoryParseId.Trim() == null ||
            l_categoryParseId == "" || l_categoryParseId.Trim() == "")
        {
            l_productlist = l_access.getProductList(-1, lang);
        }
        else
        {
            int categoryID = Int32.Parse(l_categoryParseId.ToString());
            l_productlist = l_access.getProductList(categoryID, lang);
        }

        for (int i = 0; i < l_productlist.Rows.Count; i++)
        {
            String path = "http://www.newrising.com.hk";
            String httpPath = path + l_productlist.Rows[i]["productPhoto"].ToString();
            l_productlist.Rows[i]["productPhoto"] = httpPath;
        }

        listViewProductList.DataSource = l_productlist;
        listViewProductList.DataBind();

       // GridViewProductList.DataSource = l_productlist;
        //GridViewProductList.PageSize = 10;
        //GridViewProductList.AllowPaging = true;
        //GridViewProductList.RowCommand += new GridViewCommandEventHandler(GridViewProductList_ItemCommand);
        //GridViewProductList.DataBind();   
    } 

母版页更改语言的超链接:

母版页.aspx

     <asp:HyperLink ID="linkChi" runat="Server"                           
                       ImageUrl="images/chinese.png"  />
                    <asp:HyperLink ID="linkEng" runat="Server"                           
                        ImageUrl="images/english.png" />

MasterPage.aspx.cs

    linkChi.NavigateUrl = "?currentculture=zh-hk";
linkEng.NavigateUrl = "?currentculture=en-us";

每当我按linkChi或linkEng切换语言时,它显示页面是空白的..

请您告诉我如何确保 categoryID 的值可以保留在页面回发下?

4

1 回答 1

1

我不明白你的问题是什么,但如果你问在回发后如何保持价值,你总是可以使用

ViewState["categoryID"] = categoryID;
于 2013-06-26T17:22:49.007 回答