Thanks Decker... I used your code and your gridview and got nothing to display so I am still looking for a complete answer if anyone is willing. Thanks in advance
Here is he code and the grid view that didnt work.
protected void Page_Load(object sender, EventArgs e)
{
string filePath = Server.MapPath("App_Data/test.xml");
var result = from f in XDocument.Load(filePath).Descendants("Floor")
select new
{
FloorName = f.Value,
DepartNames = from g in f.Descendants("Department")
select g.Value
};
}
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="false" Enabled="true"
Visible="true" OnLoad="gvload">
<Columns>
<asp:TemplateField HeaderText="FloorName">
<ItemTemplate><%#Eval("FloorName")%></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Departments">
<ItemTemplate><%#Eval("Department")%></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
bprego
Member
205 Points
46 Posts
Re: get XML file into a grid view
Apr 16, 2012 06:04 PM|LINK
Thanks Decker... I used your code and your gridview and got nothing to display so I am still looking for a complete answer if anyone is willing. Thanks in advance
Here is he code and the grid view that didnt work.
protected void Page_Load(object sender, EventArgs e) { string filePath = Server.MapPath("App_Data/test.xml"); var result = from f in XDocument.Load(filePath).Descendants("Floor") select new { FloorName = f.Value, DepartNames = from g in f.Descendants("Department") select g.Value }; } <asp:GridView id="GridView1" runat="server" AutoGenerateColumns="false" Enabled="true" Visible="true" OnLoad="gvload"> <Columns> <asp:TemplateField HeaderText="FloorName"> <ItemTemplate><%#Eval("FloorName")%></ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Departments"> <ItemTemplate><%#Eval("Department")%></ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>