Create a Web Application in Visual Studio 2010 to store product details in XML format. Display product details in a GridView and add an advertisement banner using AdRotator control. Bind XML data to the GridView and set up advertisement files for banner display.
Suppose we have the requirement that a website needs to create a Web Application to store the details in the XML data format of the products available for sale. The details of the products should be displayed in a data grid. The details include product ID, product name, description, price, quantity available, and category. The form should have an advertisement banner. When the user clicks the banner, the order form of the WebShoppe Website should be displayed.
Let's have a look at the following steps:
<?xml version="1.0" encoding="utf-8"?> <productdata> <product category="toy"> <prodid> P001 </prodid> <productname>Mini Bus</productname> <description>This is a toy for children aged 4 and above</description> <price>75</price> <qtyavilable>54</qtyavilable> </product> <product category="toy"> <prodid> P002 </prodid> <productname>Barbie Doll</productname> <description>This is a toy for children in the age group of 5-10</description> <price>100</price> <qtyavilable>200</qtyavilable> </product> </productdata>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; public partial class myform : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.ReadXml(MapPath("Product.xml")); GridView1.DataSource = ds; GridView1.DataBind(); } }
<?xml version="1.0" encoding="utf-8" ?> <Advertisements> <Ad> <ImageUrl>http://localhost:1330/productdetails/Images/myshopping.jpg</ImageUrl> <NavigateUrl>http://localhost:1330/productdetails/Onlineshopping.aspx</NavigateUrl> <AlternateText>The Order Online Form for WebShoppe</AlternateText> <Impressions>1</Impressions> </Ad> <Ad> <ImageUrl>http://localhost:1330/productdetails/Images/barbiel2.jpg</ImageUrl> <NavigateUrl>http://localhost:1330/productdetails/Onlineshopping.aspx</NavigateUrl> <AlternateText>The Order Online Form for WebShoppe</AlternateText> <Impressions>2</Impressions> </Ad> </Advertisements>
.NET Interview Questions and Answer: Practical Implementation