views:

23

answers:

1
        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>
A: 

FYI, it seems like a listview bug. Here's a hack around it :-P http://bytes.com/topic/asp-net/answers/536803-finding-parent-control-value-nested-datalist-c

kenyee
ok...more ugh...the actual problem for me is that you can't use Eval inside a LayoutTemplate in that nested listview. You can try hacking it in ItemDataBound and setting an Asp:Literal but in the nested listview, the control IDs are all screwed up (ctlXX instead of what you specify). I ended up just moving the <ul> to the itemtemplate of the outer listview and that met my needs...sometimes the simplest solution is the best :-)
kenyee