我想筛选不同的记录基础。我用下面的代码绑定不同的数据到中继器使用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