XML, dataset, and DataGrid are combined into the ad Management Program (on)

Source: Internet
Author: User
Author: http://www.aspcn.com flying knife

This article describes the usage of XML in ASP. Net. Here, I only show the usage of XML and DataSet. In fact, ASP. Net has many methods and objects for XML operations, such as XmlDataDocument and XmlTextReader. These objects are fully functional and practical.

This article takes the XML used by the Adrotator control as an example (for beginners, let's take a look at the usage of the Adrotator control) and write an advertisement management program. In this program, the control used by the flying knife is mainly the DataGrid. It can be said that almost all functions of the DataGrid have been used. while paying attention to XML, you can learn how to use the DataGrid at the same time.

First, we will explain some of the methods used in this example:

DataSet mainly uses ReadXml and WriteXml methods. Their functions will be known by name, and the flying knife will not be so arrogant.

The DataGrid uses many methods and objects. For example, the AllowPaging attribute is used for paging and the AllowSorting attribute is used for sorting. In this example, all events in the DataGrid are used, such as OnItemCommand, OnEditCommand, OnCancelCommand, and OnUpdateCommand.

Check the handling of these events carefully.

In addition, when you look at the program, think about the number of pages required for the program to be written using ASP. net only needs one page and is used infinitely. This is ASP. net.

In the program, I made some simple comments. The most important thing is everyone's understanding.

Well, our studio has been busy recently, so please forgive me. Flying knife does not write programs these days, but all the programs to be written must be published in books. (for example, a Web page with the same functionality as hunting software can really implement the same functionality as hunting, no false information. This will be scolded :)

Let's take a look at the content of the XML file we operate on:

 

<? Xml version = "1.0" standalone = "yes"?>
<Advertisements>
<XSD: schema id = "advertisements" targetnamespace = "" xmlns = ""
Xmlns: XSD = "http://www.w3.org/1999/XMLSchema"
Xmlns: msdata = "urn: Schemas-Microsoft-com: XML-msdata">
<XSD: element name = "ad">
<XSD: complextype content = "elementonly">
<XSD: All>
<XSD: element name = "imageurl" minoccurs = "0" type = "XSD: string"/>
<XSD: element name = "navigateurl" minoccurs = "0" type = "XSD: string"/>
<XSD: element name = "alternatetext" minoccurs = "0" type = "XSD: string"/>
<Xsd: element name = "Keyword" minOccurs = "0" type = "xsd: string"/>
<Xsd: element name = "Impressions" minOccurs = "0" type = "xsd: string"/>
</Xsd: all>
</Xsd: complexType>
</Xsd: element>
<Xsd: element name = "Advertisements" msdata: IsDataSet = "True">
<Xsd: complexType>
<Xsd: choice maxOccurs = "unbounded">
<Xsd: element ref = "Ad"/>
</Xsd: choice>
</Xsd: complexType>
</Xsd: element>
</Xsd: schema>
<Ad>
<ImageUrl> aspcn_bbs1.gifc </ImageUrl>
Http://www.aspcn.com/bbs <NavigateUrl> </NavigateUrl>
<AlternateText> ASPCN? /AlternateText>
<Keyword> bbs </Keyword>
<Impressions> 50 </Impressions>
</Ad>
<Ad>
<ImageUrl> aspcn_bbs3.gif </ImageUrl>
Http://www.aspcn.com/bbs <NavigateUrl> </NavigateUrl>
<AlternateText> ASPCN? /AlternateText>
<Keyword> bbs </Keyword>
<Impressions> 50 </Impressions>
</Ad>
<Ad>
<ImageUrl> aspcn_bbs2.gifc </ImageUrl>
Http://www.aspcn.com/bbs <NavigateUrl> </NavigateUrl>
<AlternateText> ASPCN? /AlternateText>
<Keyword> bbs2 </Keyword>
<Impressions> 50 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> why is it true? /AlternateText>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> why is it true? /AlternateText>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> why is it true? /AlternateText>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> why is it true? /AlternateText>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <imageurl> </imageurl>
Http://www.aspcn.com <navigateurl> </navigateurl>
<Alternatetext> why is it true? /Alternatetext>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <imageurl> </imageurl>
Http://www.aspcn.com <navigateurl> </navigateurl>
<Alternatetext> why is it true? /Alternatetext>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> why is it true? /AlternateText>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> why is it true? /AlternateText>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> why is it true? /AlternateText>
<Keyword> Juan Xiaobang? /Keyword>
<Impressions> 80 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
Http://www.aspcn.com <NavigateUrl> </NavigateUrl>
<AlternateText> click here to get rid of ddd </AlternateText>
<Keyword> dd </Keyword>
<Impressions> 98090 </Impressions>
</Ad>
<Ad>
Http://www.aspcn.com/aspcn.gif <ImageUrl> </ImageUrl>
<NavigateUrl> </NavigateUrl>
<AlternateText> zookeeper and zookeeper sdfasfad </AlternateText>
<Keyword> dd </Keyword>
<Impressions> 98090 </Impressions>
</Ad>
<Ad>
Http://wwwaspcn.com <ImageUrl> </ImageUrl>
<NavigateUrl> http: // </NavigateUrl>
<AlternateText> </AlternateText>
<Keyword> </Keyword>
<Impressions> </Impressions>
</Ad>
</Advertisements>

Chinese is a bit of a problem, but it can be displayed normally in the following program, because the international technology is used, haha, there are many things in this example :)

This is the standard format XML referenced by the Adrotator control.

Next, let's take a look at the source code of ASP. Net.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.