Hi this is for binding xml file to a gridview.
i used this code in load event.it is working.
i want to write this in a function.
ie if i enter name in a textbox and enter the button the corresponding city and age should be displayed.
XDocument xmlDoc = XDocument.Load(Server.MapPath("People.xml"));
var persons = from person in xmlDoc.Descendants("Person")
select new
{
Name = person.Element("Name").Value,
City = person.Element("City").Value,
Age = person.Element("Age").Value,
};
GridView1.DataSource = persons;
GridView1.DataBind();
i tried this type
public string bind(string ename)
{
XDocument xmlDoc = XDocument.Load(Server.MapPath("People.xml"));
var persons = from person in xmlDoc.Descendants("Person") where name==ename
select new
{
Name = person.Element("Name").Value,
City = person.Element("City").Value,
Age = person.Element("Age").Value,
};
return persons;
}
how it possible
Regards
K L BAIJU