Question:You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a product information page that contains the following control.

<asp:GridView ID="grdDisplay" runat="server" />

You declare a string variable named xmlFragment that contains the following XML fragment.

<Products>
<Product price="35" />
<Product price="12" />
</Products>

You need to display the prices for the two products from the XML fragment. Which code segment should you use?

 

A var xmlStream = new StringReader(xmlFragment);
var ds = new DataSet("Product");
ds.ReadXml(xmlStream);
grdDisplay.DataSource = ds.Tables[0];
grdDisplay.DataBind(); 

B var xmlStream = new StringReader(xmlFragment);
var ds = new DataSet("Product");
ds.InferXmlSchema(xmlStream, null);
ds.ReadXml(xmlFragment);
grdDisplay.DataSource = ds.Tables[0];
grdDisplay.DataBind(); 

C var xdd = new XmlDataDocument();
xdd.LoadXml(xmlFragment);
grdDisplay.DataSource = xdd.DataSet.Tables[0];
grdDisplay.DataBind(); 

D var ds = new DataSet("Product");
var xdd = new XmlDataDocument(ds);
xdd.LoadXml(xmlFragment);
grdDisplay.DataSource = ds.Tables[0];
grdDisplay.DataBind(); 

+ Answer
+ Report
Total Preview: 1341

Copyright © 2024. Powered by Intellect Software Ltd