locked
xml data binding error RRS feed

  • Question

  • User-1327517459 posted

    Hai Guys,

    This is my code...

    protected void Page_Load(object sender, EventArgs e)
            {

                //Converting  XML data into DataTable first and then binding the DataTable object to GridView           
                 DataTable dt = new DataTable();
                //string a = HttpContext.Current.Server.MapPath(@"~/App_Data/AppList.xml");
                 dt.ReadXml(MapPath(@"~/App_Data/AppList.xml"));
                 GridView1.DataSource = dt;
                //binding is done
                GridView1.DataBind();
    }

    When i debug i am getting the error at the line highlighted as

    DataTable does not support schema inference from Xml.

    Help me in resolving the above issue

    Thursday, January 3, 2013 3:58 AM

Answers

  • User-422529730 posted

    use dataset

    //Converting  XML data into DataTable first and then binding the DataTable object to GridView           
                 DataSet dt = new DataSet();
                //string a = HttpContext.Current.Server.MapPath(@"~/App_Data/AppList.xml");
                 dt.ReadXml(MapPath(@"~/App_Data/AppList.xml"));
                 GridView1.DataSource = dt.Tables[0];
                //binding is done
                GridView1.DataBind();



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 3, 2013 4:15 AM