0

这是我的代码

 var q = from a in bh
                join b in hr on a.HotelCode equals b.hotelCode
                select new
        {
            a.HotelCode,
            a.ImageURL_Text,
            a.HotelName,
            a.StarRating,    
            a.HotelAddress,
            a.Destination,
            a.Country,
            a.HotelInfo,
            a.Latitude,
            a.Longitude,
            b.totalPrice,
            b.totalPriceSpecified,
            b.totalSalePrice,
            b.totalSalePriceSpecified,
            b.rooms

    };

        //rptHotels.DataSource = getres.availableHotels;

        PagedDataSource objPds = new PagedDataSource();
        objPds.DataSource = q;
        objPds.AllowPaging = true;
        objPds.PageSize = 10;// Convert.ToInt32(ddlPageNo.SelectedValue);

        objPds.CurrentPageIndex = CurrentPage;

        lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
           + objPds.PageCount.ToString();

        // Disable Prev or Next buttons if necessary
        cmdPrev.Enabled = !objPds.IsFirstPage;
        cmdNext.Enabled = !objPds.IsLastPage;

        rptHotels.DataSource = objPds;
        rptHotels.DataBind();

错误有自我解释,但没有解决这个错误的方法......

4

1 回答 1

4

使用 ToArray():

objPds.DataSource = q.ToArray();
于 2012-07-24T08:39:04.753 回答