ViewState上的大对象

时间:2017-06-15 17:32:23

标签: c# asp.net viewstate

我在ViewState上存储类的对象。它有3个字符串变量。但是当一个字符串变大(超过400个字符)时,分页停止工作。

我尝试了很多东西,但没有运气。

所以我需要考虑另一种会话管理方法吗?

public class Productx
{
    public bool check { get; set; } // ForMultiProduct Page - Selected or not
    public string imagePathSmall { get; set; }
    public string imagePathLarge { get; set; }
    public int Id { get; set; }
    public int RatingCount { get; set; }
    public string SetName { get; set; }
    public string Description { get; set; }
    public string KeyWords { get; set; }
    public int FavourCount { get; set; }
}

public List<Productx> ArticleList
{
    get
    {
        if (this.ViewState["ArticleList"] != null)
        {
            return (List<Productx>)(this.ViewState["ArticleList"]);
        }
        return new List<Productx>();
    }
    set { this.ViewState["ArticleList"] = value; }
}

List<Productx> al = new List<Productx>();
foreach (DataRow dr in tblProducts.Rows)
{
    Productx a = new Productx();
    a.check = false;                      
    a.Id = Convert.ToInt32(dr["ID"].ToString());                        
    a.RatingCount = Convert.ToInt32(dr["RATING_COUNT_BY_CAT"].ToString());                                               
    string s = dr["KEY_WORDS"].ToString();                       
    a.KeyWords = s;                        
    a.FavourCount = Convert.ToInt32(dr["FAVORITE_COUNT"].ToString());                       
    al.Add(a);
}
if (al.Count > 0) ArticleList = al;

0 个答案:

没有答案