DataBinding an Arbitrary XML String to an ASP.Net GridViev

/ Published in: C#
Save to your folder(s)

Definitely falls into the category of "simple thing I shoulda memorized years ago", but whatever:

Copy this code and paste it in your HTML
  1. DataSet ds = new DataSet();
  2. string xml = GetSomeXMLFromWherever();
  4. ds.ReadXml(new StringReader(xml), XmlReadMode.InferSchema);
  5. GridView1.DataSource = ds;
  6. GridView1.DataBind();

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.