这是我的代码
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();
错误有自我解释,但没有找到解决此错误的方法......
使用ToArray():
objPds.DataSource = q.ToArray();