I’m trying to databind some information to a repeater but it seems to be showing me the data but not in the way i’d expect
Here’s the data i’m getting
Value Xml HasAttributes HasElements IsEmpty Value
1 1 False False False 1
12/12/2006 1 False False False 1
But the data I want to get is something like this
ADULTS DEPARTURE_DATE
1 12/12/2006
Here’s my LINQ and ASP.Net
Dim xel = XElement.Parse(xmlstring)
Dim flights = xel.Descendants("Flights")
Dim tests = flights.Where(Function(f) DateTime _
.Parse(f.Descendants("DEPARTURE_DATE").Value).Date <= DateTime.Now.Date) _
.OrderBy(Function(f) f.Descendants("DEPARTURE_DATE").Value)_
.ThenBy(Function(f) f.Descendants("DEPARTURE_TIME").Value)
CType(e.Item.FindControl("Repeater"), Repeater).DataSource = tests _
.Descendants().Elements()
CType(e.Item.FindControl("Repeater"), Repeater).DataBind()
Here’s some sample XML
<booking>
<travel>
<flights>
<flight id="1">
<adults>1</adults>
<departure_date>12/12/2006</departure_date>
<departure_time>08:05</departure_time>
</flight>
</flights>
</travel>
</booking>
The string xmlstring is the XML above.
Here’s my repeater
<asp:Repeater ID="Repeater" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "DEPARTURE_DATE") %>
</ItemTemplate>
</asp:Repeater>
It just keeps saying that there is no field DEPARTURE_DATE in the datasource
Any ideas how this is possible if it is?
Try changing your query to something like this…