Converting XML File to Dataset and Binding Dataset To GridViewUsing Asp.Net



Introduction:

Here i will Explain How to convert XML File To Dataset and Binding Dataset To GridView using asp.net

C# Code:

1.Open New Website in VS and Add WebForm To Website.
2.Add Grid View Control to webform and set the id of gridview as grid.
3.In .cs file add below name spaces
    using System.Data;
using System.Data.SqlClient;
4.Add Below code to page load()


protected void Page_Load(object sender, EventArgs e)

    {
        DataSet ds = new DataSet();
        ds.ReadXml("D:/Book2.xml");
        grid.DataSource = abc;
        grid.DataBind();
    }
5.Run your application(Press F5)

OutPut:



c_Project_Primary_Sno c_Project_Primary_Code c_Project_Primary_Name c_Project_Primary_Spcification c_Project_Primary_Description c_Project_Primary_DeveloperName c_Project_Primary_StartingDate c_Project_Primary_EndingDate c_Project_Primary_CompletedDate c_Project_Primary_RegistationDate
9 321312 fdgg dfgfdg fdgfdgd fdgfdgg 2009-09-16T00:00:00+05:30 2009-09-25T00:00:00+05:30 2009-09-23T00:00:00+05:30 2009-09-22T05:12:43.047+05:30
4 34532532 gryry hgfhgfh hggfhfh gfhfghh 2009-09-02T00:00:00+05:30 2009-09-24T00:00:00+05:30 2009-09-23T00:00:00+05:30 2009-09-22T00:34:31.97+05:30