ASP.NET read XML data into Gridview

ASP.NET , CRM , XML , Gridview Denver, United States
  • 11 years ago

    Hello all. I am new to ASP.NET XML so I am looking for some guidance. I have an XML string that needs to read into an ASP.NET C# Gridview. The XML data actually comes from the CRM SDK crm web service (FetchXML). The XML Elements contain (dots) and attributes which seem to be the issue here. If I do a Replace on the XML and remove the DOT, I still cannot read the entire XML string into Gridview because there is an attribute with that element. (notice the ppl.amount)

    Here is the XML output that was generated from FetchXML: Device with Standard Service for Warranty Device with Standard Service for Warranty {245798D8-0660-DE11-8B1F-00237D653ED0} {C9D286D4-AE18-DE11-8153-00237D653ED0} 20 RF Remote RF Remote {BF107F7D-A461-DE11-8B1F-00237D653ED0} {C9D286D4-AE18-DE11-8153-00237D653ED0} 25

    I need some code that would read this XML properly into a dataset that I can assign to the Gridview datasource.

    Here is the code I am using now: DataSet ds = new DataSet(); result1 = MY XML STRING FROM FETCHXML StringReader rdr; rdr = new StringReader(result1); ds.ReadXml(rdr); GridView1.DataSource = ds.Tables[1]; GridView1.DataBind();

    If I don't set AutoGenerateColumns="false" in the Gridview, it does not display the "ppl.amount" element or the ppl.transactioncurrencyid element. I need those two columns to show in the Gridview as well.

    Can someone help me get this figured out please??
    Thanks a lot!

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses” - Bjarne Stroustrup