var subfacets = from l in facets.Descendants("Facet")
let FacetName = l.Attribute("Name").Value
let DisplayedFacetAttr = l.Attribute("DisplayedName")
select new
{
DisplayedFacetName = (DisplayedFacetAttr != null) ? DisplayedFacetAttr.Value : FacetName,
FacetName,
SubFacets = (from x in l.Descendants("SubFacet")
let SubFacetName = x.Attribute("Name").Value
let DisplayedSubFacetAttr = x.Attribute("DisplayedName")
select new {
FacetName,
SubFacetName = (DisplayedSubFacetAttr != null) ? DisplayedSubFacetAttr.Value : SubFacetName,
SubFacetCount = x.Attribute("Count").Value
}).Take(dispitems.ContainsKey(FacetName) ? dispitems[FacetName] : defitemcount)
};
I'm a bit baffled at this....I'm using the results of this in a nested Listview and the FacetName value in the inner "select new" doesn't get filled in...it's blank. I can't figure out if this is a bug in the asp.net 3.5 listview control or the linq query is wrong. In the debugger, the FacetName looks right in the subquery, so is this a bug in the ListView?
Here's the Listview code:
<asp:ListView runat="server" ID="FacetList"
ItemPlaceholderID="PlaceHolder2">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="PlaceHolder2" />
</LayoutTemplate>
<ItemTemplate>
<h1><%# Eval("DisplayedFacetName") %></h1>
<asp:ListView runat="server" ID="SubFacetList"
ItemPlaceholderID="PlaceHolder3"
DataSource='<%# Eval("SubFacets") %>'>
<LayoutTemplate>
<ul id='<%# Eval("FacetName") %>'>
<asp:PlaceHolder runat="server" ID="PlaceHolder3" />
<li class="morefacets"><a href='#' onclick="ekt_MoreFacets('<%# Eval("FacetName") %>')">More...</a></li>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<div class="nowrap">
<input type="checkbox" name='<%# Eval("FacetName") %>' value='<%# Eval("SubFacetName") %>' />
<a href='<%# Eval("SubFacetName") %>'><%# Eval("SubFacetName")%></a> (<%# Eval("SubFacetCount")%>)
</div>
</li>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>