2

首先,我想说,啊!!

在这个线程停止的地方挑选

基本上,该线程是关于无法在启用缓存的情况下对通用列表进行排序。我尝试了多种回复,但没有运气。好像我很接近但到目前为止...

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
    //What goes in this area?
    CheckExpiredCacheKey(argRefresh);
    ObjectDataSource1.SelectParameters["sortBy"].DefaultValue = string.Format("{0} {1}", e.SortExpression, e.SortDirection == SortDirection.Ascending ? "ASC" : "DESC");                     
    e.Cancel = true;
}

public void CheckExpiredCacheKey(string ckey)
{
    if (Cache[ckey] == null)
        Cache[ckey] = new object(); //Set Cache key which will b used to manually expire ODS cache     

    if (!IsPostBack && Request.QueryString["refresh"] == "1")//check refresh flag
    {
        //Cache.Remove(ckey);//NOT NEEDED: use the following instead
        Cache[ckey] = new object();// Needed otherwise it'll call Grid-populate twice
    }
}

这是 Select 方法,在尝试这种对通用列表进行排序和缓存的方式时,sortBy 字符串始终为空?

[DataObject(true)]
public class BusinessLogic
{
    [DataObjectMethod(DataObjectMethodType.Select, true)]
    public static List<Customer> GetCustomers(int financeId, int startIndex, int pageSize, string sortBy)
    {
        return DataAccess.GetCustomers(financeId, startIndex, pageSize, sortBy);
    }
4

0 回答 0