我使用下面的代码后泛型列表排序上绑定一个分页数据源到中继器控制使用.Toarray方法
protected void Paging()
{
Array q = (Array)Session["q"];
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = q;
objPds.AllowPaging = true;
objPds.PageSize = 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();
}
其中q
是
getAvailableHotelResponse getres = new getAvailableHotelResponse();
getres = objsoap.getAvailableHotel(apiKey, destinationId, checkIn, checkOut, strCurrencyCode, "UK", false, rooms, f);
List<hotel> hr = new List<hotel>();
hr = getres.availableHotels.ToList();
List<BALHotelList> bh = new List<BALHotelList>();
bh = h.GetHotelListByDestinationId(destinationId);
var q = from a in bh
join b in hr on a.HotelCode equals b.hotelCode
orderby a.HotelName
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;
Session["q"] = q.ToArray();
现在我想用
想要通过hotelname
或starRating
对数组q排序。
我没有找到任何方法等
q.sort();
或
q.orderBy(q->hotelName)
add'using System.Linq;' – 2012-07-27 18:47:08
@TimSchmelter我已经有了这个命名空间。 – rahularyansharma 2012-07-27 18:48:45