I have a login page where the user chooses their name from a dropdown list then enters their id code in a text box. The page then redirects to the account page where the user's information is displayed. The dropdown list and the text box are being loaded and checked against an xml file, here's an example from it.
<staff>
<idcode>0200</idcode>
<Name id="0200">Doe, John</Name>
</staff>
I want the account page to check for the id attribute in the Name node to display the user's name in a label. I've tried using the method described here: C# Linq to XML query, but the output to the label I get is this "System.Linq.Enumerable+WhereEnumerableIterator`1[System.Xml.Linq.XElement]". Here's my code:
XDocument xdoc = XDocument.Load(Server.MapPath("Staff.xml"));
var result = xdoc.Descendants("Staff").Elements("Name").Where(n => n.Attribute("id").Value == inputPassword);
nameLabel.Text = result.ToString();
inputPassword is the idcode from the previous page and that loads correctly.
Am I missing something simple or would it be easier to restructure the xml so that the Name node is a child of the idcode node? Thanks.