Wednesday, March 2, 2016

How to retrieving Data from XML FileGrid view Using C# SharePoint

XML file inside:
<?xml version="1.0" encoding="utf-8" ?>
<Contacts>
  <Contact>
  <Fname>India</Fname>
  <City>Chennai</City>
  <Telno>99999999</Telno>
  </Contact>
  
  <Contact>
  <Fname>SW</Fname>
  <City>rome</City>
  <Telno>999999999</Telno>
    </Contact>


C# coding:
protected void Page_Load(object sender, EventArgs e)
    {
        GridView1.DataSource = getContacts();
        GridView1.DataBind();

      
    }
    public DataSet getContacts()
    {
        dSet = new DataSet();
        dSet.ReadXml(Server.MapPath("Contacts.xml"));
        return dSet;

    }

No comments:

Post a Comment