首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

高手们看这段代码怎么解决

2012-01-10 
高手们看这段代码如何解决.使用了AspNetPagerC# codepublic partial class _Default : System.Web.UI.Page

高手们看这段代码如何解决.
使用了AspNetPager

C# code
 
  public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
              Bind(this.Pager.CurrentPageIndex,this.Pager.PageSize);
           
            }
        }
        public void Bind(int PageIndex,int PageSize)
        {
           
           
              using(NorthWindDataContext nor = new NorthWindDataContext())
                {
                var suppliers = from s in nor.Suppliers
                                where s.Products.Count > 4
                                select s;
                this.Repeater1.DataSource = suppliers;
                this.Repeater1.DataBind();
             
                    var result = from c in nor.Customers
                        join o in nor.Orders
                        on c.CustomerID equals o.CustomerID
                        into custorder
                        from o in custorder
                        select new
                        {
                            Customer = c.CompanyName,
                            OrderDate = o.OrderDate,
                            OrderTotal = o.Order_Details.Sum(p => p.UnitPrice)
                        };
                 
                  this.GridView1.DataSource=result.Skip((PageIndex-1)*PageSize).Take(PageSize);       
                  this.GridView1.DataBind();
                  this.Pager.RecordCount = result.Count();
                  this.Pager.PageSize = GridView1.PageSize;

              }
        }

        protected void Pager_PageChanged(object sender, EventArgs e)
        {
            this.GridView1.PageIndex = this.Pager.CurrentPageIndex;
            Bind(this.GridView1.PageIndex, this.Pager.PageSize);
        }

     
    }


点下一页或其他页就报错
HTML code
 
此提供程序只支持对返回实体或投影(包含所有标识列)的有序查询使用 Skip(),这种查询为单表(非联接)查询,或者为 Distinct、Except、Intersect 或 Union (非 Concat)操作。




[解决办法]
是的。。。来晚了。。。。。。。
[解决办法]
你分页的事件写错了 Pager_PageChangeing 事件才对。。。
[解决办法]
恭喜楼主自己找到答案了。
[解决办法]
接分了

热点排行