我想篩選不同的記錄基礎。我用下面的代碼綁定不同的數據到中繼器使用linq來反對不同
List<BALHotelList> searchresult = (from a in bh
join b in hr on a.HotelCode equals b.hotelCode
orderby a.HotelName
select new BALHotelList
{
HotelCode = a.HotelCode,
ImageURL_Text = a.ImageURL_Text,
HotelName = a.HotelName,
StarRating = a.StarRating,
HotelAddress = a.HotelAddress,
Destination = a.Destination,
Country = a.Country,
HotelInfo = a.HotelInfo,
Latitude = a.Latitude,
Longitude = a.Longitude,
HotelArea=a.HotelArea,
totalPrice = b.totalPrice,
totalPriceSpecified = b.totalPriceSpecified,
totalSalePrice = b.totalSalePrice,
totalSalePriceSpecified = b.totalSalePriceSpecified,
rooms = b.rooms,
boardType = b.boardType
}).ToList();
var uniqueArea =searchresult.Select(m => m.HotelArea).Distinct();
rptHotelArea.DataSource = uniqueArea;
rptHotelArea.DataBind();
但它沒有在數據源中找到HotelArea。
但是當我調試它顯示我的所有不同的值在uniqueArea
誤差如下:
DataBinding: 'System.String' does not contain a property with the name 'HotelArea'.
EDITED
這裏是轉發器HTML
<asp:Repeater ID="rptHotelArea" runat="server">
<ItemTemplate>
<div class="sub-part1">
<a href="#"><%#Eval("HotelArea")%></a></div>
</ItemTemplate>
</asp:Repeater>
請大家看看答案這個問題:http://stackoverflow.com/questions/ 5011617/ASP淨中繼器綁定-liststring。 – 2012-07-30 08:44:31
@Serge +1其作品。還有一件事是否null在特定情況下被視爲唯一 – rahularyansharma 2012-07-30 08:48:50
是否要跳過null? – 2012-07-30 08:55:56